[Sussex] Label and partition external hard drive

Steven Dobson steve at dobbo.org
Tue Feb 22 17:51:20 UTC 2011


Hi Fay

On 22/02/11 15:48, 'Fay Zee' wrote:
> I've acquired a 3 1/2" 160GB e-SATA hard drive in an external USB
> case that I want to use to back up my files.

Is this for backing up Linux systems only?  The reason I asked is that
if it is then you can use a *nix filesystem rather than one that has
wider acceptance.

I use XFS (which was first developed by SGI, although there are other
filesystems like ext2/3/4, JFS and others) for which the command is:

# mkfs -t xfs -L <label> <device>

Where <label> is the label you want (e.g. "Backup") and <device> is the
device which from below whould be "/dev/sdf1".

>                                              I need to give it a
> meaningful volume name to distinguish it from my other external
> devices and I've searched and found some of the commands I need. But
> I'm stuck on steps 4, 5 and 6 below. Please could someone help me out?
> My preference is always for CLI over graphical as I can save the
> commands for future use.
> 
> ---------------------------------------------------------
> 1. Discover the device name allocated to the external hdd
> and find out how many partitions it has
> ---------------------------------------------------------
> BEFORE attaching external hdd:
> $ ls -l /dev/sd*
> Now attach external hdd and re-run above command. Look for the added
> line.
> 
> RESULT:
> brw-rw---- 1 root disk   8, 80 2011-02-19 23:45 /dev/sdf
> brw-rw---- 1 root disk   8, 81 2011-02-19 23:45 /dev/sdf1
> 
> ---------------------------------------------------------
> 2. Discover the size of the external hard drive partition
> ---------------------------------------------------------
> # df /dev/sdf1
> (If multiple partitions, run $ df /dev/sdf*)
> 
> RESULT:
> Filesystem            Size  Used Avail Use% Mounted on
> /dev/sdf1             150G   91M  149G   1%
> /media/New Volume
> 
> ---------------------------------------------------------------------
> 3. Assign Dos type device name to the external hdd prior to using
> mlabel
> ---------------------------------------------------------------------
> # cat /etc/mtools.conf
> # echo -e "ndrive x: file="/dev/sdf1"" >> /etc/mtools.conf

The echo command doesn't look right to me.  The quotes will be
interrited by the command shell.  What you are trying to do is
add the line:
    ndrive x: file="/dev/sdf1"

to the end of the file.  You need to use the command:
	# echo -e "ndrive x: file=\"/dev/sdf1\"" >> /etc/mtools.conf

The backslashes are important.

> ---------------------------------------------------
> 4. Display existing volume name of the external hdd
> ---------------------------------------------------
> # mlabel ????????
> I want to know how to view the label first.
> I'm nervous at this point as I don't want to corrupt the drive.

Having just tried it mlabel displays any label if there is one before
asking you want you want the new label to be.

	# mlabel r:
	 Volume label is RedDisk (abbr=REDDIS~1àÀ¶)
	Enter the new volume label : RedFlash
	#

However the screen partitioning tool "cfdisk" will display the partition
table and any labels it finds there in:

	# cfdisk -P s /dev/sdc

                       cfdisk (util-linux-ng 2.17.2)

                              Disk Drive: /dev/sdc
                        Size: 1000275456 bytes, 1000 MB
               Heads: 64   Sectors per Track: 32   Cylinders: 953

    Name  Flags Part Type  FS Type  [Label]        Size (MB)
   ------------------------------------------------------------
    sdc4  Boot  Primary    FAT16    [REDFLASH]     999.30


   [ Bootable ]  [  Delete  ]  [   Help   ]  [ Maximize ]  [  Print   ]
   [   Quit   ]  [   Type   ]  [  Units   ]  [  Write   ]

                  Quit program without writing partition table

	<I hit Q to quite the program at this point>

> 
> ---------------------------------------------
> 5. Give the external hard drive a volume name
> ---------------------------------------------
> mlabel or e2label or tune2fs are mentioned on this link:
> http://www.linuxquestions.org/questions/linux-general-1/how-to-change-volume-label-of-the-usb-drives-594875/
> But the instructions aren't precise enough - I don't want to corrupt
> the disk!
> 
> ------------------------------------------------------------------
> 6. Partition the external hdd into 3 partitions of 50GB each
> Format one for a Windows file system and the others for Linux only
> ------------------------------------------------------------------
> I also need help here! This is my first external device large enough
> to benefit from partitioning (I've only ever partitioned during OS
> installation until now).

Make sure the disk hasn't been auto mounted.

Then cfdisk to re-partition the disk first.  It's not hard to use

    1). First delete any existing partitions
    2). Then create the partitions you want
    3). Then assign the types to the partitions.

Then you can use "mkfs" to lay a filesystem down.

Steve
-- 
Steve "Dobbo" Dobson



More information about the Sussex mailing list