f013
![]() |
|
|
|
|
|||||||
| Storage Place to ask questions about partitioning, labelling, filesystems, encryption or anything else related to storage area. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi fellows,
Code:
truncate -s 1G /mnt/VirtualDisk chmod 0600 /mnt/VirtualDisk mdconfig -a -t vnode -f /mnt/VirtualDisk Code:
rc_debug="YES" rc_info="YES" mdconfig_md2="-t vnode -f /mnt/VirtualDisk" /etc/rc.d/mdconfig start and /etc/rc.d/mdconfig2 start but nothing helped, md2 wasn't listed by mdconfig -lv After scanning a bit through the rc.d/mdconfig scripts, I figured it may want to have the actual md_n_ device to start so I tried /etc/rc.d/mdconfig start md2 and voila:Code:
FreeBSD [~]# mdconfig -lv
md0 swap 512M
md1 vnode 4096M /var/swap
FreeBSD [~]# /etc/rc.d/mdconfig start md2
/etc/rc.d/mdconfig: DEBUG: run_rc_command: start_precmd: [ -n "${_mdconfig_list}" ]
/etc/rc.d/mdconfig: DEBUG: load_kld: geom_md kernel module already loaded.
/etc/rc.d/mdconfig: DEBUG: run_rc_command: doit: mdconfig_start
/etc/rc.d/mdconfig: DEBUG: md2 config: -t vnode -f /mnt/VirtualDisk
/etc/rc.d/mdconfig: DEBUG: md2 type: vnode
/etc/rc.d/mdconfig: DEBUG: md2 dev: /dev/md2
/etc/rc.d/mdconfig: DEBUG: md2 file: /mnt/VirtualDisk
/etc/rc.d/mdconfig: DEBUG: md2 fs: /
/etc/rc.d/mdconfig: DEBUG: md2 newfs flags:
Creating md2 device (vnode).
/etc/rc.d/mdconfig: DEBUG: checkyesno: background_fsck is set to YES.
fsck: Could not determine filesystem type
Fsck failed on /dev/md2, not mounting the filesystem.
FreeBSD [~]# mdconfig -lv
md0 swap 512M
md1 vnode 4096M /var/swap
md2 vnode 1024M /mnt/VirtualDisk
FreeBSD [~]# mdconfig -du 2
mdconfig -lv But then I tried rc.d/mdconfig2 and it doesn't seem to complain about fsck:Code:
FreeBSD [~]# /etc/rc.d/mdconfig2 start md2
/etc/rc.d/mdconfig2: DEBUG: run_rc_command: start_precmd: [ -n "${_mdconfig2_list}" ]
/etc/rc.d/mdconfig2: DEBUG: load_kld: geom_md kernel module already loaded.
/etc/rc.d/mdconfig2: DEBUG: run_rc_command: doit: mdconfig2_start
/etc/rc.d/mdconfig2: DEBUG: md2 config: -t vnode -f /mnt/VirtualDisk
/etc/rc.d/mdconfig2: DEBUG: md2 type: vnode
/etc/rc.d/mdconfig2: DEBUG: md2 dev: /dev/md2
/etc/rc.d/mdconfig2: DEBUG: md2 file: /mnt/VirtualDisk
/etc/rc.d/mdconfig2: DEBUG: md2 fs: /
/etc/rc.d/mdconfig2: DEBUG: md2 owner:
/etc/rc.d/mdconfig2: DEBUG: md2 perms:
/etc/rc.d/mdconfig2: DEBUG: md2 files:
/etc/rc.d/mdconfig2: DEBUG: md2 populate cmd:
/etc/rc.d/mdconfig2: DEBUG: checkyesno: _mounted is set to no.
mdconfig -lv doesn't list it - so it's not configured?So what am I doing wrong? My aim is to initialize a simple md device right at system boot in order to let eg. iSCSI (istg) benefit of the md device. Any hints or ideas? Last edited by DutchDaemon; April 23rd, 2012 at 23:51. Reason: Proper formatting: http://forums.freebsd.org/showthread.php?t=8816 |
|
#2
|
|||
|
|||
|
Have you tried changing the variable in rc.conf to mdconfig_md0 instead of mdconfig_md2?
I've no experience with the mdconfig startup script but I wouldn't be surprised if it runs in a loop, looking for 0 first, processing that, then 1, etc. The ifconfig scripts work like this for aliases. You'll probably find it's looking for mdconfig_md0, not finding it and giving up (unless you specify the md number as you say). That may make /etc/rc.d/mdconfig start work but looking at the script I can't see any obvious way of stopping it trying to format and mount the device. You may end up having to make a custom rc script to run the commands on boot. Last edited by DutchDaemon; April 27th, 2012 at 01:50. Reason: Proper formatting: http://forums.freebsd.org/showthread.php?t=8816 |
|
#3
|
|||
|
|||
|
The following rc script should create the required md device on boot and remove it on shutdown (tested on 8.3-RELEASE). I'm not sure whether istg will be starting/stopping on boot/shutdown but if so the REQUIRE/KEYWORD stuff at the top may require tweaking to make sure istg starts after this and stops first.
(Note the device is hardcoded to /dev/md100) Code:
#!/bin/sh
# PROVIDE: iscsimd
# REQUIRE: LOGIN
# KEYWORD: shutdown
. /etc/rc.subr
name="iscsimd"
rcvar="iscsimd_enable"
start_cmd="iscsimd_start"
stop_cmd="iscsimd_stop"
disk="/mnt/VirtualDisk"
size="1G"
iscsimd_start()
{
/usr/bin/truncate -s ${size} ${disk}
/bin/chmod 0600 ${disk}
/sbin/mdconfig -a -t vnode -f ${disk} -u 100
}
iscsimd_stop()
{
/sbin/mdconfig -d -u 100
/bin/unlink ${disk}
}
load_rc_config $name
run_rc_command "$1"
Code:
iscsimd_enable="YES" It will then run on boot/shutdown and can be run manually as follows: Code:
# service iscsimd start # service iscsimd stop Last edited by DutchDaemon; April 27th, 2012 at 22:54. |
|
#4
|
|||
|
|||
|
Nice work, hey!
Thanks a lot
|
|
#5
|
|||
|
|||
|
Here is a tuned version of previous rc script. The method of evaluating md[n] is limited to 100 only! Please let me know if someone knows a better way of getting the "n" of md_file_md[n]. I tried my luck in this thread: http://forums.freebsd.org/showthread.php?t=31707
rc.conf entries can look like: Code:
### Memory Disks md_enable="YES" md_file_md0="/mnt/VirtualDisk" md_file_md1="/mnt/FileX" md_file_md12="/mnt/SomeOtherFile" Code:
#!/bin/sh
# PROVIDE: md
# REQUIRE: localswap root
# BEFORE: SERVERS
. /etc/rc.subr
name="md"
rcvar="md_enable"
start_cmd="${name}_start"
stop_cmd="md_stop"
required_modules="geom_md:g_md"
md_start() {
for i in $(seq 0 100); do
unset MD_FILE
eval MD_FILE=\$md_file_md${i}
if [ ! -z $MD_FILE ]; then
if [ -f $MD_FILE ]; then
if [ ! -z "$(/sbin/mdconfig -lv | /usr/bin/grep "${MD_FILE}")" ]; then
USED_MD="$(/sbin/mdconfig -lv | /usr/bin/grep "${MD_FILE}" | awk '{print $1}')"
echo "mdconfig: Skipped md${i}. File $MD_FILE is configured as $USED_MD already."
unset USED_MD
else
/sbin/mdconfig -a -t vnode -f $MD_FILE -u ${i} && \
MSG="mdconfig: Created /dev/md${i}" && \
SIZE=$(diskinfo -v /dev/md${i} | grep "mediasize in bytes" | grep -E -o "\(.*\)") && \
printf "%s %s %-10s %s\n" $MSG $SIZE
fi
else
echo "mdconfig: Error: Skipped md${i}. File $MD_FILE not found."
fi
fi
done
}
md_stop() {
echo "Sorry - this script does not support \"stop\". Use i.e."
echo "'mdconfig -du 3' in order to unconfigure /dev/md3"
}
load_rc_config $name
run_rc_command "$1"
chmod 0555 /usr/local/etc/rc.d/md the rc script. There is no stop since stop could cause collateral damage to data on md. There is also no file creation if a file doesn't exist. It is necessary to invoke i.e.Code:
truncate -s 1G /mnt/VirtualDisk chmod 0600 /mnt/VirtualDisk Code:
service md start Last edited by DutchDaemon; April 30th, 2012 at 02:15. Reason: Formatting & Style: http://forums.freebsd.org/showthread.php?t=8816 / http://forums.freebsd.org/showthread.php?t=18043 |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| System boot error after System upgrade | hp21 | Installing & Upgrading | 0 | November 19th, 2010 12:00 |
| [Solved] mdconfig and device numbers | tobe | Userland Programming & Scripting | 6 | June 12th, 2009 13:30 |
| mdconfig: Writeable Vnode, is it possible? | vaclinux | General | 4 | March 17th, 2009 07:18 |
| low perfomance throuch mdconfig layer | Ole | General | 0 | February 3rd, 2009 12:46 |
| Can't boot system | randux | Installing & Upgrading | 3 | February 2nd, 2009 17:31 |