ubuntu修改盘符名称

碰到的问题

我在移动硬盘中下载了一套代码,在编译的时候出现了如下错误:

1
2
3
4
5
6
7
8
9
10
11
Checking build tools versions...
build/core/main.mk:115: ************************************************************
build/core/main.mk:116: You are building in a directory whose absolute path contains
build/core/main.mk:117: a space character:
build/core/main.mk:118:
build/core/main.mk:119: "/media/victor/My Passport/code/xxx"
build/core/main.mk:120:
build/core/main.mk:121: Please move your source tree to a path that does not contain
build/core/main.mk:122: any spaces.
build/core/main.mk:123: ************************************************************
build/core/main.mk:124: *** Directory names containing spaces not supported. Stop.

很明显,我的编译路径存在空格,也就是我移动硬盘的盘符名称My Passport有空格,突然感觉WD的硬盘好low啊。。。
此时就要去修改硬盘盘符名称。


解决办法

必须将移动硬盘盘符名称改掉,以下介绍在ubuntu中怎么一步步修改盘符名称。
1、查看类型

1
2
3
4
5
6
# sudo blkid
/dev/sda1: UUID="4488-EAF5" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="0875dd30-1da5-4303-987f-73a7ee9c41b5"
/dev/sda2: UUID="8cefef49-192c-4f78-879d-725feb2c9f97" TYPE="ext4" PARTUUID="066a86a5-e1da-4f63-a110-1abc15e1f4e6"
/dev/sda3: UUID="fecf47eb-ec23-4c80-9c4f-8f0074bcf2ea" TYPE="swap" PARTUUID="5aa677f9-1fd6-45ff-a9ca-cb1c90ac705e"
/dev/sdb1: UUID="3a68ba27-4dd6-41a9-bc12-8cf4301ea6eb" TYPE="ext4" PARTUUID="cf96ad83-01"
/dev/sdc1: LABEL="My Passport" UUID="B84067E64067AA38" TYPE="ntfs" PARTLABEL="My Passport" PARTUUID="5608a181-0df2-4693-af16-84189f9aebca"

我们可以知道,这个硬盘是ntfs格式,label为My Passport

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# sudo fdisk -l
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 1AB1B218-1445-4A7C-8C0C-1E9EDB7A7545

Device Start End Sectors Size Type
/dev/sda1 2048 1050623 1048576 512M EFI System
/dev/sda2 1050624 974772223 973721600 464.3G Linux filesystem
/dev/sda3 974772224 976771071 1998848 976M Linux swap


Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xcf96ad83

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1953525167 1953523120 931.5G 83 Linux


Disk /dev/sdc: 1.8 TiB, 2000365289472 bytes, 3906963456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: AC76A599-ACF4-4252-AC38-25379D722DF8

Device Start End Sectors Size Type
/dev/sdc1 2048 3906961407 3906959360 1.8T Microsoft basic data

2、umount掉设备

1
# sudo umount /dev/sdc1

3、针对ntfs类型的设备,使用ntfslabel修改盘符名称:

1
# sudo ntfslabel /dev/sdc1 victor_disk

4、重新插拔移动硬盘即可


参考资料

https://help.ubuntu.com/community/RenameUSBDrive

  • 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

Title:ubuntu修改盘符名称

Author:Victor Huang

Time:2019-06-08 / 15:06

Link:http://wowothink.com/d2bb7d25/

License: Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)