在sdb上挂载USB 设备
2012-11-12 10:28
447 查看
在主机上挂载 USB 设备后我们查看系统当前磁盘设备:
1. [root@FCoE ~]# fdisk -l
2.
3. Disk /dev/sda: 43.0 GB, 42991616000 bytes
4. 255 heads, 63 sectors/track, 5226 cylinders
5. Units = cylinders of 16065 * 512 = 8225280 bytes
6. Sector size (logical/physical): 512 bytes / 512 bytes
7. I/O size (minimum/optimal): 512 bytes / 512 bytes
8. Disk identifier: 0x00032735
9.
10. Device Boot Start End Blocks Id System
11. /dev/sda1 * 1 17 131072 83 Linux
12. Partition 1 does not end on cylinder boundary.
13. /dev/sda2 17 147 1048576 82 Linux swap / Solaris
14. Partition 2 does not end on cylinder boundary.
15. /dev/sda3 147 5227 40803328 83 Linux
16.
17. Disk /dev/sdb: 2147 MB, 2147483648 bytes
18. 255 heads, 63 sectors/track, 261 cylinders
19. Units = cylinders of 16065 * 512 = 8225280 bytes
20. Sector size (logical/physical): 512 bytes / 512 bytes
21. I/O size (minimum/optimal): 512 bytes / 512 bytes
22. Disk identifier: 0x00000000
23.
24. Disk /dev/sdb doesn't contain a valid partition table
ocp认证现在我们在 sdb 这个设备上创建一个新的分区:
1. [root@FCoE ~]# fdisk /dev/sdb
2. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
3. Building a new DOS disklabel with disk identifier 0xcdd48395.
4. Changes will remain in memory only, until you decide to write them.
5. After that, of course, the previous content won't be recoverable.
6.
7. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
8.
9. WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
10. switch off the mode (command 'c') and change display units to
11. sectors (command 'u').
12.
13. Command (m for help): n
14. Command action
15. e extended
16. p primary partition (1-4)
17. p
18. Partition number (1-4): 1
19. First cylinder (1-261, default 1):
20. Using default value 1
21. Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
22. Using default value 261
23.
24. Command (m for help): p
25.
26. Disk /dev/sdb: 2147 MB, 2147483648 bytes
27. 255 heads, 63 sectors/track, 261 cylinders
28. Units = cylinders of 16065 * 512 = 8225280 bytes
29. Sector size (logical/physical): 512 bytes / 512 bytes
30. I/O size (minimum/optimal): 512 bytes / 512 bytes
31. Disk identifier: 0xcdd48395
32.
33. Device Boot Start End Blocks Id System
34. /dev/sdb1 1 261 2096451 83 Linux
35.
36. Command (m for help): w
37. The partition table has been altered!
38.
39. Calling ioctl() to re-read partition table.
40. Syncing disks.
ocp认证在新分区 sdb1 上创建文件系统:
1. [root@FCoE ~]# mkfs.ext3 /dev/sdb1
2. mke2fs 1.41.12 (17-May-2010)
3. Filesystem label=
4. OS type: Linux
5. Block size=4096 (log=2)
6. Fragment size=4096 (log=2)
7. Stride=0 blocks, Stripe width=0 blocks
8. 131072 inodes, 524112 blocks
9. 26205 blocks (5.00%) reserved for the super user
10. First data block=0
11. Maximum filesystem blocks=536870912
12. 16 block groups
13. 32768 blocks per group, 32768 fragments per group
14. 8192 inodes per group
15. Superblock backups stored on blocks:
16. 32768, 98304, 163840, 229376, 294912
17.
18. Writing inode tables: done
19. Creating journal (8192 blocks): done
20. Writing superblocks and filesystem accounting information: done
21.
22. This filesystem will be automatically checked every 24 mounts or
23. 180 days, whichever comes first. Use tune2fs -c or -i to override.
ocp认证挂载新的文件系统:
1. [root@FCoE ~]# mount /dev/sdb1 /mnt/
ocp认证通常我们通过备份硬盘的 MBR 来备份硬盘分区表:
1. [root@FCoE ~]# dd if=/dev/sda of=/mnt/sda.mbr bs=512 count=1
2. 1+0 records in
3. 1+0 records out
4. 512 bytes (512 B) copied, 0.000777948 s, 658 kB/s
ocp认证现在我们来写零硬盘分区表来实现类似分区表被破坏的结果:
1. [root@FCoE ~]# dd if=/dev/zero of=/dev/sda bs=1 count=64 skip=446 seek=446
2. 64+0 records in
3. 64+0 records out
4. 64 bytes (64 B) copied, 0.00160668 s, 39.8 kB/s
ocp认证查询硬盘 sda 上的分区信息,发现其已不包含任何分区:
1. [root@FCoE ~]# fdisk -l
2.
3. Disk /dev/sda: 43.0 GB, 42991616000 bytes
4. 255 heads, 63 sectors/track, 5226 cylinders
5. Units = cylinders of 16065 * 512 = 8225280 bytes
6. Sector size (logical/physical): 512 bytes / 512 bytes
7. I/O size (minimum/optimal): 512 bytes / 512 bytes
8. Disk identifier: 0x00032735
9.
10. Device Boot Start End Blocks Id System
11.
12. Disk /dev/sdb: 2147 MB, 2147483648 bytes
13. 255 heads, 63 sectors/track, 261 cylinders
14. Units = cylinders of 16065 * 512 = 8225280 bytes
15. Sector size (logical/physical): 512 bytes / 512 bytes
16. I/O size (minimum/optimal): 512 bytes / 512 bytes
17. Disk identifier: 0xcdd48395
18.
19. Device Boot Start End Blocks Id System
20. /dev/sdb1 1 261 2096451 83 Linux
当主机硬盘分区表丢失了之后,再次启动后 GRUB 会因找不到配置文件而进入命令行模式。
1. [root@FCoE ~]# fdisk -l
2.
3. Disk /dev/sda: 43.0 GB, 42991616000 bytes
4. 255 heads, 63 sectors/track, 5226 cylinders
5. Units = cylinders of 16065 * 512 = 8225280 bytes
6. Sector size (logical/physical): 512 bytes / 512 bytes
7. I/O size (minimum/optimal): 512 bytes / 512 bytes
8. Disk identifier: 0x00032735
9.
10. Device Boot Start End Blocks Id System
11. /dev/sda1 * 1 17 131072 83 Linux
12. Partition 1 does not end on cylinder boundary.
13. /dev/sda2 17 147 1048576 82 Linux swap / Solaris
14. Partition 2 does not end on cylinder boundary.
15. /dev/sda3 147 5227 40803328 83 Linux
16.
17. Disk /dev/sdb: 2147 MB, 2147483648 bytes
18. 255 heads, 63 sectors/track, 261 cylinders
19. Units = cylinders of 16065 * 512 = 8225280 bytes
20. Sector size (logical/physical): 512 bytes / 512 bytes
21. I/O size (minimum/optimal): 512 bytes / 512 bytes
22. Disk identifier: 0x00000000
23.
24. Disk /dev/sdb doesn't contain a valid partition table
ocp认证现在我们在 sdb 这个设备上创建一个新的分区:
1. [root@FCoE ~]# fdisk /dev/sdb
2. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
3. Building a new DOS disklabel with disk identifier 0xcdd48395.
4. Changes will remain in memory only, until you decide to write them.
5. After that, of course, the previous content won't be recoverable.
6.
7. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
8.
9. WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
10. switch off the mode (command 'c') and change display units to
11. sectors (command 'u').
12.
13. Command (m for help): n
14. Command action
15. e extended
16. p primary partition (1-4)
17. p
18. Partition number (1-4): 1
19. First cylinder (1-261, default 1):
20. Using default value 1
21. Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
22. Using default value 261
23.
24. Command (m for help): p
25.
26. Disk /dev/sdb: 2147 MB, 2147483648 bytes
27. 255 heads, 63 sectors/track, 261 cylinders
28. Units = cylinders of 16065 * 512 = 8225280 bytes
29. Sector size (logical/physical): 512 bytes / 512 bytes
30. I/O size (minimum/optimal): 512 bytes / 512 bytes
31. Disk identifier: 0xcdd48395
32.
33. Device Boot Start End Blocks Id System
34. /dev/sdb1 1 261 2096451 83 Linux
35.
36. Command (m for help): w
37. The partition table has been altered!
38.
39. Calling ioctl() to re-read partition table.
40. Syncing disks.
ocp认证在新分区 sdb1 上创建文件系统:
1. [root@FCoE ~]# mkfs.ext3 /dev/sdb1
2. mke2fs 1.41.12 (17-May-2010)
3. Filesystem label=
4. OS type: Linux
5. Block size=4096 (log=2)
6. Fragment size=4096 (log=2)
7. Stride=0 blocks, Stripe width=0 blocks
8. 131072 inodes, 524112 blocks
9. 26205 blocks (5.00%) reserved for the super user
10. First data block=0
11. Maximum filesystem blocks=536870912
12. 16 block groups
13. 32768 blocks per group, 32768 fragments per group
14. 8192 inodes per group
15. Superblock backups stored on blocks:
16. 32768, 98304, 163840, 229376, 294912
17.
18. Writing inode tables: done
19. Creating journal (8192 blocks): done
20. Writing superblocks and filesystem accounting information: done
21.
22. This filesystem will be automatically checked every 24 mounts or
23. 180 days, whichever comes first. Use tune2fs -c or -i to override.
ocp认证挂载新的文件系统:
1. [root@FCoE ~]# mount /dev/sdb1 /mnt/
ocp认证通常我们通过备份硬盘的 MBR 来备份硬盘分区表:
1. [root@FCoE ~]# dd if=/dev/sda of=/mnt/sda.mbr bs=512 count=1
2. 1+0 records in
3. 1+0 records out
4. 512 bytes (512 B) copied, 0.000777948 s, 658 kB/s
ocp认证现在我们来写零硬盘分区表来实现类似分区表被破坏的结果:
1. [root@FCoE ~]# dd if=/dev/zero of=/dev/sda bs=1 count=64 skip=446 seek=446
2. 64+0 records in
3. 64+0 records out
4. 64 bytes (64 B) copied, 0.00160668 s, 39.8 kB/s
ocp认证查询硬盘 sda 上的分区信息,发现其已不包含任何分区:
1. [root@FCoE ~]# fdisk -l
2.
3. Disk /dev/sda: 43.0 GB, 42991616000 bytes
4. 255 heads, 63 sectors/track, 5226 cylinders
5. Units = cylinders of 16065 * 512 = 8225280 bytes
6. Sector size (logical/physical): 512 bytes / 512 bytes
7. I/O size (minimum/optimal): 512 bytes / 512 bytes
8. Disk identifier: 0x00032735
9.
10. Device Boot Start End Blocks Id System
11.
12. Disk /dev/sdb: 2147 MB, 2147483648 bytes
13. 255 heads, 63 sectors/track, 261 cylinders
14. Units = cylinders of 16065 * 512 = 8225280 bytes
15. Sector size (logical/physical): 512 bytes / 512 bytes
16. I/O size (minimum/optimal): 512 bytes / 512 bytes
17. Disk identifier: 0xcdd48395
18.
19. Device Boot Start End Blocks Id System
20. /dev/sdb1 1 261 2096451 83 Linux
当主机硬盘分区表丢失了之后,再次启动后 GRUB 会因找不到配置文件而进入命令行模式。
相关文章推荐
- Linux下如何挂载FAT32格式USB设备
- 树莓派-USB存储设备自动挂载
- Raspberry Pi 自动挂载USB存储设备
- 在linux中的virtualbox无法挂载usb设备的解决方法
- usb设备被多次挂载问题
- 在嵌入式开发平台中实现USB设备的自动挂载
- ubunut下挂载多个USB设备并拷贝资料
- android 6.0检查设备是否挂载SD卡,USB设备
- Raspberry Pi 自动挂载USB存储设备
- Raspberry Pi-2 启动自动挂载USB设备
- Android usb client mass-storage挂载单个存储设备研究
- 在虚拟机环境下挂载USB设备到Linux
- VirtualBox 中如何访问 USB 设备 关键字:vbox usb 访问 挂载 gpasswd 虚拟机 ubuntu linux
- 用udev自动挂载usb设备
- 树莓派USB存储设备自动挂载
- linux环境下挂载(mount)USB设备
- Debian系统不能挂载exFAT类型格式化后的USB设备
- TP-LINK WR703N 刷OpenWrt并设置pppoe联网、安装LUCI、添加新用户、挂载USB设备、配置ftp服务、借由transmission实现脱机下载
- 在虚拟机VMware Workstation下挂载USB设备到Linux
- 树莓派Raspberry Pi实战之命令行下实现USB存储设备自动挂载