[关闭]
@fanisfun 2017-03-07T02:12:23.000000Z 字数 4924 阅读 2919

Linux U盘分区

Linux


1. 查看U盘分区号

  1. sudo fdisk -l
  1. Device Boot Start End Blocks Id System
  2. /dev/sda1 1 3907029167 1953514583+ ee GPT
  3. Partition 1 does not start on physical sector boundary.
  4. Disk /dev/mapper/ubuntu--vg-root: 1931.0 GB, 1930973675520 bytes
  5. 255 heads, 63 sectors/track, 234760 cylinders, total 3771432960 sectors
  6. Units = sectors of 1 * 512 = 512 bytes
  7. Sector size (logical/physical): 512 bytes / 4096 bytes
  8. I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  9. Disk identifier: 0x00000000
  10. Disk /dev/mapper/ubuntu--vg-root doesn\'t contain a valid partition table
  11. Disk /dev/mapper/ubuntu--vg-swap_1: 68.6 GB, 68627202048 bytes
  12. 255 heads, 63 sectors/track, 8343 cylinders, total 134037504 sectors
  13. Units = sectors of 1 * 512 = 512 bytes
  14. Sector size (logical/physical): 512 bytes / 4096 bytes
  15. I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  16. Disk identifier: 0x00000000
  17. Disk /dev/mapper/ubuntu--vg-swap_1 doesn\'t contain a valid partition table
  18. Disk /dev/sdb: 31.1 GB, 31104958464 bytes
  19. 255 heads, 63 sectors/track, 3781 cylinders, total 60751872 sectors
  20. Units = sectors of 1 * 512 = 512 bytes
  21. Sector size (logical/physical): 512 bytes / 512 bytes
  22. I/O size (minimum/optimal): 512 bytes / 512 bytes
  23. Disk identifier: 0x91cd37a8
  24. Device Boot Start End Blocks Id System
  25. /dev/sdb1 * 784384 60751871 29983744 c W95 FAT32 (LBA) ## <- here!

可以看出U盘分区号是: /dev/sdb1

2. U盘分区

  1. sudo fdisk /dev/sdb
  1. Command (m for help): m ## 打印命令列表
  2. Command action
  3. a toggle a bootable flag # 将分区标记为可启动盘
  4. b edit bsd disklabel
  5. c toggle the dos compatibility flag
  6. d delete a partition # 删除一个分区
  7. l list known partition types
  8. m print this menu
  9. n add a new partition
  10. o create a new empty DOS partition table
  11. p print the partition table
  12. q quit without saving changes
  13. s create a new empty Sun disklabel
  14. t change a partition\'s system id
  15. u change display/entry units
  16. v verify the partition table
  17. w write table to disk and exit
  18. x extra functionality (experts only)
  19. Command (m for help): p ## 打印U盘分区: /dev/sdb1
  20. Disk /dev/sdb: 31.1 GB, 31104958464 bytes
  21. 255 heads, 63 sectors/track, 3781 cylinders, total 60751872 sectors
  22. Units = sectors of 1 * 512 = 512 bytes
  23. Sector size (logical/physical): 512 bytes / 512 bytes
  24. I/O size (minimum/optimal): 512 bytes / 512 bytes
  25. Disk identifier: 0x91cd37a8
  26. Device Boot Start End Blocks Id System
  27. /dev/sdb1 * 784384 60751871 29983744 c W95 FAT32 (LBA)
  28. Command (m for help): d ## 删除原本分区
  29. Selected partition 1
  30. Command (m for help): p ## 打印U盘分区: 无
  31. Disk /dev/sdb: 31.1 GB, 31104958464 bytes
  32. 255 heads, 63 sectors/track, 3781 cylinders, total 60751872 sectors
  33. Units = sectors of 1 * 512 = 512 bytes
  34. Sector size (logical/physical): 512 bytes / 512 bytes
  35. I/O size (minimum/optimal): 512 bytes / 512 bytes
  36. Disk identifier: 0x91cd37a8
  37. Device Boot Start End Blocks Id System
  38. Command (m for help): n ## 新建分区
  39. Partition type:
  40. p primary (0 primary, 0 extended, 4 free)
  41. e extended
  42. Select (default p): p ## 基本分区
  43. Partition number (1-4, default 1): 2 ## 指定为2号分区
  44. First sector (2048-60751871, default 2048):
  45. Using default value 2048
  46. Last sector, +sectors or +size{K,M,G} (2048-60751871, default 60751871): +2G ## 大小为2G
  47. Command (m for help): p ## 打印分区: /dev/sdb2
  48. Disk /dev/sdb: 31.1 GB, 31104958464 bytes
  49. 255 heads, 63 sectors/track, 3781 cylinders, total 60751872 sectors
  50. Units = sectors of 1 * 512 = 512 bytes
  51. Sector size (logical/physical): 512 bytes / 512 bytes
  52. I/O size (minimum/optimal): 512 bytes / 512 bytes
  53. Disk identifier: 0x91cd37a8
  54. Device Boot Start End Blocks Id System
  55. /dev/sdb2 2048 4196351 2097152 83 Linux
  56. Command (m for help): n
  57. Partition type:
  58. p primary (1 primary, 0 extended, 3 free)
  59. e extended
  60. Select (default p): p ## 基本分区
  61. Partition number (1-4, default 1): 1 ## 指定为2号分区
  62. First sector (4196352-60751871, default 4196352):
  63. Using default value 4196352
  64. Last sector, +sectors or +size{K,M,G} (4196352-60751871, default 60751871): ## 剩余所有空间
  65. Using default value 60751871
  66. Command (m for help): p ## 打印分区: /dev/sdb1 & /dev/sdb2
  67. Disk /dev/sdb: 31.1 GB, 31104958464 bytes
  68. 255 heads, 63 sectors/track, 3781 cylinders, total 60751872 sectors
  69. Units = sectors of 1 * 512 = 512 bytes
  70. Sector size (logical/physical): 512 bytes / 512 bytes
  71. I/O size (minimum/optimal): 512 bytes / 512 bytes
  72. Disk identifier: 0x91cd37a8
  73. Device Boot Start End Blocks Id System
  74. /dev/sdb1 4196352 60751871 28277760 83 Linux ## 数据分区
  75. /dev/sdb2 2048 4196351 2097152 83 Linux ## 启动分区
  76. Command (m for help): w ## 保存修改并退出
  77. The partition table has been altered!

注意: Windows下默认只识别 1号分区,因此将数据分区指定为1号 /dev/sdb1

3. 格式文件系统

  1. sudo mkfs.ntfs -f -L NTFS /dev/sdb1 ## NTFS
  2. sudo mkfs.vfat -F 32 /dev/sdb2 ## FAT32

数据分区为 NTFS 以支持大于4G文件的存取,启动分区为 FAT32 获得更好的兼容性。

4. 加载U盘分区

  1. sudo mkdir -p /mnt/usb1
  2. sudo mount -t auto /dev/sdb1 /mnt/usb1
  3. sudo mkdir -p /mnt/usb2
  4. sudo mount -t auto /dev/sdb2 /mnt/usb2
  5. sudo df -h ## 打印文件系统信息
  1. Filesystem Size Used Avail Use% Mounted on
  2. /dev/mapper/ubuntu--vg-root 1.8T 3.4G 1.7T 1% /
  3. none 4.0K 0 4.0K 0% /sys/fs/cgroup
  4. udev 32G 4.0K 32G 1% /dev
  5. tmpfs 6.3G 1.5M 6.3G 1% /run
  6. none 5.0M 0 5.0M 0% /run/lock
  7. none 32G 144K 32G 1% /run/shm
  8. none 100M 36K 100M 1% /run/user
  9. /dev/sda2 237M 45M 180M 20% /boot
  10. /dev/sda1 511M 3.4M 508M 1% /boot/efi
  11. /dev/sdb2 27G 16K 2.0G 1% /mnt/usb2 # <- here
  12. /dev/sdb1 2.0G 16K 27G 1% /mnt/usb1 # <- here

4. Clonezilla启动 Extension

Clonezilla(再生龙)是一款遵守GUN授权方式的自由软件,它基于Partimage,吸取了Norton Ghost和Partition Image的优点。即不仅支持对整个硬盘系统进行克隆,而且也可以克隆单个的分区,这种灵活性更能满足各种使用者的需要,此外支持多种的操作系统与文件系统也是其强大之处。我主要使用Clonezilla对Windows和Linux系统环境进行的备份、还原和部署。单台部署,选择最新的 Live 稳定版。

mark

  1. sudo unzip clonezilla.zip -d /mnt/usb2
  2. cd /mnt/usb2/utils/linux
  3. sudo ./makeboot.sh /dev/sdb2
  4. sudo apt-get install -y libc6-i386 # may need

Clonezilla 具体使用方法参考 百度文库: Clonezilla(再生龙)用户指南

5. 卸载U盘

  1. sudo umount /mnt/usb1 && sudo rm -r /mnt/usb1
  2. sudo umount /mnt/usb2 && sudo rm -r /mnt/usb2

提示: 每次拔出U盘前,请保持 卸载 的好习惯。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注