0

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.

2 Answers 2

2

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.

5
  • I want to run hdparm on physical disk, but i dont want to use sdX/hdX names. This names could be changed if i'll plug in another HDD. So im trying to use hdparm with some unique identifier like disk-UUID.
    – MealstroM
    Jul 23, 2012 at 5:54
  • Did you read my answer? Jul 23, 2012 at 13:51
  • thats IS a problem. /dev/disk/by-uuid/ contains 4 uuids: 2 system,1 swap, 1 md0 entries. There is NO uuid of physical disks of raid. Thats the problem and my question there. Sorry, havent point it in question.
    – MealstroM
    Jul 24, 2012 at 19:24
  • Please paste the actual output from ls -l /dev/disk/by-uuid. Jul 24, 2012 at 19:45
  • i've updated info.
    – MealstroM
    Jul 25, 2012 at 19:20
2

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.

1
  • i've tryed to avoid writing any script and use /etc/hdparm.conf with option disk-uuid write_cache off.
    – MealstroM
    Jul 23, 2012 at 6:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .