把SD卡制作为启动卡的操作步骤

该博客详细记录了如何在Ubuntu系统中使用fdisk命令对SD卡进行分区操作,包括删除原有分区、创建新分区、设置分区类型(FAT32和EXT4)、激活引导标志以及最后的格式化操作,以便用于不同的存储需求。
摘要由CSDN通过智能技术生成

把sd卡分为2个分区:一个为fat格式,另一个为ext4格式;

输入lsblk 查看当前U盘的挂载路径:

ubuntu$ lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb      8:16   0  200G  0 disk /media/lanxinhua/rcar-dev
sr0     11:0    1 1024M  0 rom  
fd0      2:0    1    4K  0 disk 
sdc      8:32   1  7.5G  0 disk 
├─sdc2   8:34   1    7G  0 part /media/rootfs
└─sdc1   8:33   1  500M  0 part /media/boot
sda      8:0    0  200G  0 disk 
├─sda2   8:2    0    1K  0 part 
├─sda5   8:5    0  975M  0 part [SWAP]
└─sda1   8:1    0  199G  0 part /
sr1     11:1    1 1024M  0 rom  

以下红色字体为需要输入的命令:

ubuntu:$ umount /dev/sdc1
ubuntu:$ umount /dev/sdc2
ubuntu:$ sudo fdisk /dev/sdc
Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table

删除原来创建的分区
Command (m for help): d
Partition number (1,2, default 2): 

Partition 2 has been deleted.

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

创建第一个分区并分配大小:

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-15523839, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-15523839, default 15523839): +500M

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

创建第二个分区:

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 (1026048-15523839, default 1026048): 
Last sector, +sectors or +size{K,M,G,T,P} (1026048-15523839, default 15523839): 

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

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

The bootable flag on partition 1 is enabled now.

Command (m for help): t
Partition number (1,2, default 2): 1
Partition type (type L to list all types): c

Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

Command (m for help): t
Partition number (1,2, default 2): 2
Partition type (type L to list all types): 83

Changed type of partition 'Linux' to 'Linux'.

查看:

Command (m for help): p
Disk /dev/sdc: 7.4 GiB, 7948206080 bytes, 15523840 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: 0x7422f324

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sdc1  *       2048  1026047  1024000  500M  c W95 FAT32 (LBA)
/dev/sdc2       1026048 15523839 14497792  6.9G 83 Linux

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

sudo mkfs.vfat -F 32 -n boot /dev/sdc1 

sudo mkfs.ext4 -L rootfs /dev/sdc2

ubuntu:$ sudo mkfs.vfat -F 32 -n boot /dev/sdc1
mkfs.fat 3.0.28 (2015-05-16)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
ubuntu:$ sudo mkfs.ext4 -L rootfs /dev/sdc2
mke2fs 1.42.13 (17-May-2015)
/dev/sdc2 contains a ext4 file system labelled 'rootfs'
    last mounted on /media/lanxinhua/rootfs on Fri Nov 26 09:57:06 2021
Proceed anyway? (y,n) y
Creating filesystem with 1812224 4k blocks and 453376 inodes
Filesystem UUID: 04a8382f-d690-4ee7-a77d-fa942c0adce9
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值