个人工具
登录
查看“UbuntuHelp:RenameUSBDrive”的源代码 - Ubuntu中文
UbuntuHelp
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“UbuntuHelp:RenameUSBDrive”的源代码
来自Ubuntu中文
←
UbuntuHelp:RenameUSBDrive
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{From|https://help.ubuntu.com/community/RenameUSBDrive}} {{Languages|UbuntuHelp:RenameUSBDrive}} https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconDisks.png This guide is for editing partition labels (disk names) for FAT16/FAT32, NTFS, ext2/ext3, JFS, ReiserFS, and XFS filesystems. == Partition Editor == Nautilus currently [https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/68924/ does not support renaming partitions], but Gnome's Partition Editor ([[UbuntuHelp:GParted|GParted]]) does. To change a partition's label, follow these directions. (Be careful using Partition Editor, as it's capable of making your computer completely unusable if you do the wrong thing.) <ol><li>Open the '''System''' > '''Administration''' menu and see if there's an entry for '''[[UbuntuHelp:GParted|GParted]]''' (previously '''Partition Editor'''). </li><li>If there is, launch it. If there isn't, [[UbuntuHelp:apt:gparted|install the "gparted" package]] and it should now appear in the menu. Enter your password when prompted. </li><li>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. </li><li>If the partition is mounted (has a key icon next to it), right-click on the partition and select '''Unmount'''. </li><li>With the key icon gone, right-click on the partition and select '''Label'''. If you can't select it, [[UbuntuHelp:apt:ntfsprogs|install the ntfsprogs package]]. </li><li>Enter the new partition name and press '''Ok'''. </li><li>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.</li></ol> == Command line == There are at least 6 separate command line tools used to label a partition - the program used depends on the partition's [[UbuntuHelp:LinuxFilesystemsExplained| filesystem]] type: * For '''FAT16''' and '''FAT32''' partitions, use '''mtools'''. * For '''NTFS''' partitions, use '''ntfsprogs'''. * 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''' By default, external drives automount at <code><nowiki>/media/disk</nowiki></code> then <code><nowiki>/media/disk-1</nowiki></code> 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. https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconTip.png Labeled devices that automount will be mounted in the ''/media'' directory using their label as the mount point, <code><nowiki>/media/<label></nowiki></code>. ex: <code><nowiki>/media/my_external</nowiki></code> . <<BR>>https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=warning.png When creating labels, be sure that the new mount point (based on the label) does not already exist since hal's automount function creates the directory when it mounts the device. https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=important.png 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 [[UbuntuHelp:MoveMountpointHowto|MoveMountpointHowto]] which uses the file called [[UbuntuHelp:Fstab|Fstab]]. == Identify your Partition == https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconGNOMETerminal.png For help with the terminal, see [[UbuntuHelp:UsingTheTerminal|UsingTheTerminal]]. Plug in your USB device and list your partitions with: <pre><nowiki> sudo fdisk -l </nowiki></pre> You can also list your mounted devices and their descriptions with: <pre><nowiki> mount </nowiki></pre> https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=example.png For the rest of this tutorial we will use the following: * <device> = your device /dev/sdxy, ex: ''/dev/sdb1'' * <label> = 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: <pre><nowiki> sudo apt-get install <package> </nowiki></pre> Here are all the different ones: <pre><nowiki> 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</nowiki></pre> or install the appropriate package from [[UbuntuHelp:SynapticHowto| 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: <pre><nowiki> sudo umount <device> </nowiki></pre> ex: <pre><nowiki> sudo umount /dev/sdb1</nowiki></pre> 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. === 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 ==== <pre><nowiki> sudo mlabel -i <device> -s :: </nowiki></pre> ex: <pre><nowiki> sudo mlabel -i /dev/sdb1 -s ::</nowiki></pre> 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 <code><nowiki>~/.mtoolsrc</nowiki></code> 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 <pre><nowiki> sudo mlabel -i <device> ::<label> </nowiki></pre> ex: <pre><nowiki> sudo mlabel -i /dev/sdb1 ::my_external</nowiki></pre> 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 <pre><nowiki> sudo nano /etc/mtools.conf </nowiki></pre> add something like for each drive: <pre><nowiki> drive p: file="/dev/sdb1" drive q: file="/dev/sdb2"</nowiki></pre> etc. Then use <pre><nowiki> sudo mlabel p:new_label </nowiki></pre> ex: <pre><nowiki> sudo mlabel p:30GB_FAT32</nowiki></pre> (note the underscore _ should be used, as spaces are not allowed) http://ubuntuforums.org/showpost.php?p=6356016&postcount=9 ===== Error message ===== If you get a message like this: <pre><nowiki> Total number of sectors (7831520) not a multiple of sectors per track (63)! </nowiki></pre> You can easily ignore the check by running this command: <pre><nowiki> echo mtools_skip_check=1 >> ~/.mtoolsrc </nowiki></pre> === NTFS === This filesystem is most often found on external USB and firewire hard drives or other Windows formatted disks. ==== Check the current label ==== <pre><nowiki> sudo ntfslabel <device> </nowiki></pre> ex: <pre><nowiki> sudo ntfslabel /dev/sdb1</nowiki></pre> ==== Change the label ==== Note: 128 characters maximum. <pre><nowiki> sudo ntfslabel <device> <label> </nowiki></pre> ex: <pre><nowiki> sudo ntfslabel /dev/sdb1 my_external</nowiki></pre> Ubuntu caches the drive's label so to see full affects of the change it is not enough just to umount and mount it again, the you should umount, remove, put back, mount again. === ext2, ext3, and ext4 === These filesystems are most often found on linux formatted drives. ==== Check the current label ==== <pre><nowiki> sudo e2label <device> </nowiki></pre> ex: <pre><nowiki> sudo e2label /dev/sdb1</nowiki></pre> ==== Change the label ==== Note: 16 characters maximum. <pre><nowiki> sudo e2label <device> <label> </nowiki></pre> ex: <pre><nowiki> sudo e2label /dev/sdb1 my_external</nowiki></pre> === JFS === These filesystems are most often found on IBM and some linux formatted disks. ==== Check the current label ==== <pre><nowiki> sudo jfs_tune -l <device> </nowiki></pre> ex: <pre><nowiki> sudo jfs_tune /dev/sdb1</nowiki></pre> ==== Change the label ==== Note: 16 characters maximum. <pre><nowiki> sudo jfs_tune -L <label> <device> </nowiki></pre> ex: <pre><nowiki> sudo jfs_tune -L my_external /dev/sdb1</nowiki></pre> === 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. <pre><nowiki> sudo reiserfstune -l <label> <device> </nowiki></pre> ex: <pre><nowiki> sudo reiserfstune -l my_external /dev/sdb1</nowiki></pre> === XFS === This filesystem is most often found on UNIX formatted disks. ==== Check the current label ==== <pre><nowiki> xfs_admin -l <device> </nowiki></pre> ex: <pre><nowiki> xfs_admin -l /dev/sdb1</nowiki></pre> ==== Change the label ==== Note: 12 characters maximum. <pre><nowiki> sudo xfs_admin -L <label> <device> </nowiki></pre> ex: <pre><nowiki> xfs_admin -l my_external /dev/sdb1</nowiki></pre> == 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: <pre><nowiki> sudo blkid </nowiki></pre> == Other Resources == https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconBook-small.png Some other related material: * [[UbuntuHelp:MoveMountpointHowto|MoveMountpointHowto]] * [[UbuntuHelp:LinuxFilesystemsExplained|LinuxFilesystemsExplained]] * [[UbuntuHelp:Fstab|Fstab]] * [[UbuntuHelp:MountingWindowsPartitions|MountingWindowsPartitions]] ---- [[category:CategoryUsb]] [[category:UbuntuHelp]]
该页面使用的模板:
模板:From
(
查看源代码
)
模板:Languages
(
查看源代码
)(受保护)
模板:Languages/Lang
(
查看源代码
)(受保护)
返回至
UbuntuHelp:RenameUSBDrive
。