Re: fdisk and labels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 17, 2008 at 10:50 AM, Trapper <trapper@xxxxxxxxxx> wrote:
Somewhere along the line I saw a small script that provides a display of
label information as a part of "fdisk -l" results. My searches have
proved
fruitless. Anyone recall such a script?

ValHolla, on the web forum offered this solution which apparently provides the linux labels on all connected hard drives. It works well here. Here's his script:

#!/bin/bash
OFS=${IFS}
IFS=$'\n'

printf "%-20s %-20s %-20s\n" "Device" "Type" "Volume"
for part in $(fdisk -l 2>/dev/null |grep "^/dev/" |awk '{print $1,$NF}');do
    dev=$(echo ${part} |cut -d " " -f1)
    devtype=$(echo ${part} |cut -d " " -f2)
volume=$(tune2fs -l ${dev} 2>/dev/null |grep "volume name" |awk -F ' ' '{print $NF}')
    if [ -z ${volume} ];then
        volume="no label"
    fi

    printf "%-20s %-20s %-20s\n" $dev $devtype $volume
done
IFS=${OFS}


Note .... on the line beginning with volume=$(tune2fs you may have word wrap. ' '{print $NF}') is end of line.

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux