ive got md0 (raid 1) array and want to make write cache off on them during system boot (ubuntu 12.04 server).
md0: /dev/sda /dev/sdc
blkid:
/dev/sda: UUID="3e502de5-696d-f4b4-470e-XXX" TYPE="linux_raid_member"
/dev/sdb1: UUID="4ba40aae-65e2-416b-8f17-XXX" TYPE="ext2"
/dev/sdb5: UUID="LNt5uO-ZFik-eQ0g-BEhP-FDLi-XXX" TYPE="LVM2_member"
/dev/md0: UUID="a7eb2443-c3be-45e6-a3eb-XXX" TYPE="ext4"
/dev/mapper/mydev-root: UUID="b560f808-db97-4a56-bbf1-XXX" TYPE="ext4"
/dev/sdc: UUID="3e502de5-696d-f4b4-470e-XXX" TYPE="linux_raid_member"
/dev/mapper/mydev-swap_1: UUID="49b806fe-95a6-4ddf-9c47-XXX" TYPE="swap"
hdparm -W 0 /dev/sda (or /dev/sdc) works ok, but this letters could be changed during boot. and i want to use this via disk-uuid.
**stat /dev/disk/by-uuid/*
File: `/dev/disk/by-uuid/4ba40aae-65e2-416b-8f17-XXX' -> `../../sdb1'
File: `/dev/disk/by-uuid/a7eb2443-c3be-45e6-a3eb-XXX' -> `../../md0'
File: `/dev/disk/by-uuid/49b806fe-95a6-4ddf-9c47-XXX' -> `../../dm-1'
File: `/dev/disk/by-uuid/b560f808-db97-4a56-bbf1-XXX' -> `../../dm-0'
if i use hdparm -W 0 /dev/disk/by-uuid/a7eb2443-c3be-45e6-a3eb-XXX -- this fails.
/sdb1 -- system hdd
/dm-0 -- /boot on sdb1
/dm-1 -- /root on sdb1
I'm trying to use native /etc/hdparm.conf to disable write_cache on disk-by-uuid.
i dont want to write some script to check what /dev/sdX i should use with hdparm, so im asking what to do. Please help.
You've tried to use
hdparm
on the by-uuid device file corresponding to your RAID array (md0). Instead, try running it on the ones corresponding to the physical disks.something like this one liner will run 'hdparm -W 0' on all devices that are used for md raid.
blkid | awk -F: '/linux_raid_member/ {print $1}' | xargs -r -n 1 hdparm -W 0
if you use partitions rather than whole disks for raid then you'll need to strip off the partition numbers from the device names (and unique sort them so you don't e.g. get sda three times for sda1, sda2, sda3):
blkid | awk -F: '/linux_raid_member/ {print $1}' | sed -e 's/[0-9]\+$//' | sort -u | xargs -r -n 1 hdparm -W 0
as always, first test what the one-liners are going to do by inserting an echo immediately before the hdparm. if the output looks sane, then run it again without the echo.