ubuntu 进行SD卡分区

查看当前分区

查看当前分区,dev/sdb1 /dev/sdb2就是SD卡上的两个分区

zynq@zynq:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           796M  9.4M  787M   2% /run
/dev/sda1       295G   81G  199G  29% /
tmpfs           3.9G  216K  3.9G   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           796M   68K  796M   1% /run/user/1000
/dev/sdb1       7.5G  6.7M  7.5G   1% /media/zynq/FAT
/dev/sdb2       4.6G  888M  3.5G  21% /media/zynq/EXT

fdisk进行分区操作

卸载sd

zynq@zynq:~$ umount /dev/sdb*
umount: /dev/sdb: not mounted

打开fdisk

zynq@zynq:~$ sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

查看SD信息

Command (m for help): p
Disk /dev/sdb: 14.6 GiB, 15665725440 bytes, 30597120 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: 0xa6a622b5

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sdb1           2048 15628287 15626240  7.5G  c W95 FAT32 (LBA)
/dev/sdb2       15628288 25395199  9766912  4.7G 83 Linux

删除分区

Command (m for help): d
Partition number (1,2, default 2): 1

Partition 1 has been deleted.

Command (m for help): d
Selected partition 2
Partition 2 has been deleted.

Command (m for help): 2
2: unknown command

Command (m for help): p

Disk /dev/sdb: 14.6 GiB, 15665725440 bytes, 30597120 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: 0xa6a622b5

生成分区1

生成100M的分区1

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-30597119, default 2048):      
Last sector, +sectors or +size{K,M,G,T,P} (2048-30597119, default 30597119): +100M

Created a new partition 1 of type 'Linux' and of size 100 MiB.

将分区1设置为FAT32格式

Command (m for help): t

Selected partition 1
Partition type (type L to list all types): c
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

设置为启动分区

Command (m for help): a
Selected partition 1
The bootable flag on partition 1 is enabled now.

生成分区2

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (206848-30597119, default 206848): 
Last sector, +sectors or +size{K,M,G,T,P} (206848-30597119, default 30597119): 

Created a new partition 2 of type 'Linux' and of size 14.5 GiB.

写入SD卡

Command (m for help): p
Disk /dev/sdb: 14.6 GiB, 15665725440 bytes, 30597120 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: 0xa6a622b5

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sdb1  *      2048   206847   204800  100M  c W95 FAT32 (LBA)
/dev/sdb2       206848 30597119 30390272 14.5G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

格式化sd卡

重命名sdb1并格式化

zynq@zynq:~$ sudo mkfs.vfat -F 32 -n boot /dev/sdb1
mkfs.fat 3.0.28 (2015-05-16)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows

重命名sdb2并格式化

zynq@zynq:~$ sudo mkfs.ext4 -L rootfs  /dev/sdb2
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 3798784 4k blocks and 950272 inodes
Filesystem UUID: 5cb97aac-0bc1-4185-8f7b-d255b7c44ebb
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:        
done

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值