- How can I change the hard disk name in Ubuntu?
- 5 Answers 5
- Change Name of Mounted Hard Drive
- 2 Answers 2
- RenameUSBDrive
- Using the Partition Editor
- Using the Command line
- Identify your Partition
- Install the Labeling Program
- Unmount the Partition
- Changing the Label
- Filesystems
- FAT16 and FAT32
- Check the current label
- Change the label
- Option 1
- Option 2
- Error message
- NTFS
- Check the current label
- Change the label
- ext2, ext3, and ext4
- Check the current label
- Change the label
- JFS
- Check the current label
- Change the label
- ReiserFS (v3)
- Change the label
- XFS
- Check the current label
- Change the label
- Verify the Change
- Other Resources
How can I change the hard disk name in Ubuntu?
I have a computer with Ubuntu installed. By default the hard disk name consists of a sequence of numbers and letters, which is not easy to remember nor input into a terminal. How can I change the hard disk name in Ubuntu? Which file do I need to change?
Do you mean the path to the device (/dev/sdb1), UUID (550e8400-e29b-11d4. ) or the label/name of a partition?
path to device as i understood is correct, nothing special. UUID has different mask, not the name. I mean label/name under «/media» folder. do you understand?
sorry, i just install gparted and i was wrong, i need to change UUID, because UUID and label/name under /media is same.
5 Answers 5
but if you want something with Terminal, try this
for FAT 12 and 32 Systems, these file systems are most often found on USB thumb drives, flash cards (like for a camera or cell phone), and older external USB hard drives. but may be if your hard disc is FAT 12 or 32 . Thus, check current name in terminal
for example : sudo mlabel -i /dev/sdb1 ::my_external
if not you edit mtools.conf as sudo
add something like for each drive:
drive p: file="/dev/sdb1" drive q: file="/dev/sdb2"
Then use sudo mlabel p:new_label . for example , sudo mlabel p:30GB_FAT32
first, check the current label sudo ntfslabel
and rename like that sudo ntfslabel Note: 128 characters maximum.
most of linux formatted HD are with ext3, ext4 . thus,
check the lable first sudo e2label and rename sudo e2label . Note: 16 characters maximum.
for more, you should take a look at here.
Change Name of Mounted Hard Drive
I just mounted and formatted an extra hard drive to Xubuntu, and the name is way too long for access from the terminal:
boy@boy:~$ cd /mnt/d1b2aa11-a3e4-434b-b71c-47a8ac23ac23/ boy@boy:/mnt/d1b2aa11-a3e4-434b-b71c-47a8ac23ac23$
2 Answers 2
You can use GParted to rename partition.
Launch GParted -> Unmount the drive -> Rename by setting new label.
The easiest thing to do is to for a permanent result is to give the filesystem a label. The way you do this depends on what filesystem you formatted it as. First find the device it is on:
$ findmnt /mnt/d1b2aa11-a3e4-434b-b71c-47a8ac23ac23 TARGET SOURCE FSTYPE OPTIONS . /dev/sdc1 vfat .
For example, above it is on /dev/sdc1 (check this isn’t your primary disc!) and of type vfat. So unmount the device and use
$ sudo dosfslabel /dev/sdc1 MYLABEL
Then remove the device and add it again, and (depending on your system) it should be automounted under /mnt/MYLABEL . For ext3/4, reiserfs, and xfs filesystems respectively use
$ sudo e2label /dev/sdc1 MYLABEL $ sudo reiserfstune -l MYLABEL /dev/sdc1 $ sudo xfs_admin -L MYLABEL /dev/sdc1
For permanently connected hard disks, you can usually find a mount entry for the partition in /etc/fstab (see man fstab ). The first word on a line is the device to mount: this is a name like /dev/sdx1 , or a uuid like UUID=e7522030-f6e3. , or a label like LABEL=volume . The 2nd word is the directory to use as a mount point (dir must exist). If an entry doesn’t exist for your disk, add it using preferable the UUID or LABEL in the first field, and your desired mount point, then ext4 defaults (for an ext4 filesystem).
RenameUSBDrive
This guide is primarily for external drives such as USB hard drives, USB flash drives, and flash memory cards. You can label internal disks, but to change their mount points, use MoveMountpointHowto which uses the file called Fstab. This guide covers editing partition labels (disk names) for FAT16/FAT32, NTFS, ext2/ext3, JFS, ReiserFS, and XFS filesystems.
By default, external drives automatically mounted at /media/disk then /media/disk-1 and so on. This is not very helpful when trying to find the drive you are looking for, especially if you have multiple devices plugged in. Labeled devices that are automatically mounted will be mounted in the /media directory using their label as the mount point, /media/ . ex: /media/my_external .
When choosing labels, be sure that the new mount point /media/ does not already exist since the directory will be created when the disk is mounted.
Using the Partition Editor
- Open the System >Administration menu and see if there's an entry for GParted (previously Partition Editor).
- If there is, launch it. If there isn't, install the "gparted" package and it should now appear in the menu. Enter your password when prompted.
- Disk drives are divided up into partitions. To find the partition you want to re-label, you first have to find the disk drive that contains it, using the drop-down menu in the upper right. It will show a device name like /dev/sdb and the drive's total size in parentheses. After selecting a drive, you will see a list of all partitions on that drive.
- If the partition is mounted (has a key icon next to it), right-click on the partition and select Unmount.
- With the key icon gone, right-click on the partition and select Label. If you can't select it, install the ntfsprogs package.
- Enter the new partition name and press Ok.
- The label change is now pending, but has not been completed. Press the Apply button near the top of the window. After confirming, it should say "All operations successfully completed". The drive now has a new label.
Using the Command line
- For FAT16 and FAT32 partitions, use mlabel from the mtools package.
- For NTFS partitions, use ntfslabel from the ntfs-3g package.
- For ext2, ext3, or ext4 partitions, use e2label.
- For JFS partitions, use jfs_tune.
- For ReiserFS (v3) partitions, use reiserfstune.
- For XFS partitions, use xfs_admin
Identify your Partition
For help with the terminal, see UsingTheTerminal.
Plug in your USB device and list your partitions with:
You can also list your mounted devices and their descriptions with:
For the rest of this tutorial we will use the following:
- = your device /dev/sdxy, ex: /dev/sdb1
- = your desired (new) label, ex: my_external
Install the Labeling Program
Based on the package names listed above for each filesystem type, install the correct package for your partition:
sudo apt-get install mtools sudo apt-get install ntfsprogs sudo apt-get install e2fsprogs sudo apt-get install jfsutils sudo apt-get install reiserfsprogs sudo apt-get install xfsprogs
or install the appropriate package from Synaptic.
Unmount the Partition
Partitions generally need to be unmounted before you can fiddle with them, so unmount the partition of the device you want to change the label for:
If it was automounted, you can also unmount the drive by right clicking the desktop icon and clicking Unmount (or Eject in some cases).
Changing the Label
After you complete the appropriate porition for your filesystem, jump to the next section to verify the change.
Filesystems
FAT16 and FAT32
These filesystems are most often found on USB thumb drives, flash cards (like for a camera or cell phone), and older external USB hard drives.
Check the current label
Note that we're using the special "::" drive which allows us to specify the device descriptor on the command line; otherwise we'd have to edit ~/.mtoolsrc to assign a drive letter (see Option 2 under "Change the label").
Change the label
Option 1
After unmounting and checking the current label (above), use
sudo mlabel -i /dev/sdb1 ::my_external
Ignore the "Volume label is XYZ" output as this is the old label. Jump to the Verify the Change section below.
Option 2
For Ubuntu 8.10 and up, edit mtools.conf as sudo
drive p: file="/dev/sdb1" drive q: file="/dev/sdb2"
(note the underscore _ should be used, as spaces are not allowed)
Error message
If you get a message like this:
Total number of sectors (7831520) not a multiple of sectors per track (63)!
You can easily ignore the check by running this command:
echo mtools_skip_check=1 >> ~/.mtoolsrc
NTFS
This filesystem is most often found on external USB and firewire hard drives or other Windows formatted disks.
Check the current label
Change the label
Note: 128 characters maximum.
sudo ntfslabel /dev/sdb1 my_external
Ubuntu caches the drive's label so to see the full affects of the change it is not enough just to umount and mount it again. You have to umount, remove, put back, mount again.
ext2, ext3, and ext4
These filesystems are most often found on linux formatted drives.
Check the current label
Change the label
Note: 16 characters maximum.
sudo e2label /dev/sdb1 my_external
JFS
These filesystems are most often found on IBM and some linux formatted disks.
Check the current label
Change the label
Note: 16 characters maximum.
sudo jfs_tune -L my_external /dev/sdb1
ReiserFS (v3)
This filesystem is most often found on linux formatted disks.
Note: this could work with ReiserFS 4 too, I have not tried.
Change the label
Note: 16 characters maximum.
sudo reiserfstune -l my_external /dev/sdb1
XFS
This filesystem is most often found on UNIX formatted disks.
Check the current label
Change the label
Note: 12 characters maximum.
xfs_admin -l my_external /dev/sdb1
Verify the Change
Now for the easiest part: unplug the drive, wait a second, then plug it back in. It should appear on your desktop with the new label and have its new mount point.
Without unplugging and having the device remount, you can also just run:
Other Resources
Some other related material:
- MoveMountpointHowto
- LinuxFilesystemsExplained
- Fstab
- MountingWindowsPartitions
RenameUSBDrive (последним исправлял пользователь knome 2013-12-14 11:20:15)
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details