how to know what is disk uuid for md raid1 and hdparm?

8,882

Solution 1

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.

Solution 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.

Share:
8,882

Related videos on Youtube

bonsoy
Author by

bonsoy

Updated on September 18, 2022

Comments

  • bonsoy
    bonsoy almost 2 years

    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.

  • bonsoy
    bonsoy almost 12 years
    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.
  • bonsoy
    bonsoy almost 12 years
    i've tryed to avoid writing any script and use /etc/hdparm.conf with option disk-uuid write_cache off.
  • Michael Hampton
    Michael Hampton almost 12 years
    Did you read my answer?
  • bonsoy
    bonsoy almost 12 years
    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.
  • Michael Hampton
    Michael Hampton almost 12 years
    Please paste the actual output from ls -l /dev/disk/by-uuid.
  • bonsoy
    bonsoy almost 12 years
    i've updated info.