ubuntu/Linux磁盤(pán)掛載
# fdisk -l?#查看磁盤(pán)信息
Disk /dev/ram0: 8 MiB, 8388608 bytes, 16384 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
.......
Disk /dev/mmcblk1: 3.8 GiB, 4030726144 bytes, 7872512 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: 0x00000000
Device? ? ? ? ?Boot Start? ? ?End Sectors? Size Id Type
/dev/mmcblk1p1? ? ? ?8192 7872511 7864320? 3.8G? b W95 FAT32
........
# fdisk /dev/mmcblk1p1?#進(jìn)入磁盤(pán)/TF卡/SD卡
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
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): p?#顯示該磁盤(pán)下的當(dāng)前分區(qū)信息
Disk /dev/mmcblk1p1: 3.8 GiB, 4026531840 bytes, 7864320 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: 0x00000000
Command (m for help): n??#添加一個(gè)分區(qū)
Partition type
? ?p? ?primary (0 primary, 0 extended, 4 free)?#輸入p為創(chuàng)建邏輯分區(qū)
? ?e? ?extended (container for logical partitions)?#輸入e為創(chuàng)建擴(kuò)展分區(qū)
Select (default p): p?#輸入p為創(chuàng)建邏輯分區(qū)
Partition number (1-4, default 1): 1?#劃分邏輯分區(qū)
First sector (2048-7864319, default 2048): 7864319?#磁盤(pán)分區(qū)大小
Created a new partition 1 of type 'Linux' and of size 512 B.
Command (m for help): p?#顯示該磁盤(pán)下的當(dāng)前分區(qū)信息
Disk /dev/mmcblk1p1: 3.8 GiB, 4026531840 bytes, 7864320 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: 0x00000000
Device? ? ? ? ? ?Boot? ?Start? ? ?End Sectors? Size Id Type
/dev/mmcblk1p1p1? ? ? 7864319 7864319? ? ? ?1? 512B 83 Linux
Command (m for help): w???#保存退出
The partition table has been altered.
Failed to add partition 1 to system: Invalid argument
The kernel still uses the old partitions. The new table will be used at the next reboot.?
Syncing disks.
# fdisk -l??#再次查看
.......
Disk /dev/mmcblk1: 3.8 GiB, 4030726144 bytes, 7872512 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: 0x00000000
Device? ? ? ? ?Boot Start? ? ?End Sectors? Size Id Type
/dev/mmcblk1p1? ? ? ?8192 7872511 7864320? 3.8G? b W95 FAT32
.........
# mkfs.ext4 /dev/mmcblk1p1? ??#格式化分區(qū)
mke2fs 1.44.1 (24-Mar-2018)
/dev/mmcblk1p1 contains a vfat file system
Proceed anyway? (y,N) y
/dev/mmcblk1p1 is mounted; will not make a filesystem here!
(echo /dev/vdb【磁盤(pán)分區(qū)】 /data【掛載目錄】 ext4【文件格式】 defaults 0 0 >> /etc/fstab ?#寫(xiě)入新分區(qū)信息 開(kāi)機(jī)自動(dòng)掛載 )
# echo /dev/mmcblk1p1 /data ext4 defaults 0 0 >> /etc/fstab? ? ?
# cat /etc/fstab?
# /etc/fstab: static file system information.
#
# These are the filesystems that are always mounted on boot, you can
# override any of these by copying the appropriate line from this file into
# /etc/fstab and tweaking it as you see fit.? See fstab(5).
#
# <file system> <mount point>? ? ? ? ? ? ?<type>? ? ? ? ? <options>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?<dump> <pass>
/dev/root? ? ? ? ? ? /? ? ? ? ? ? ? ? ? ? ?ext4? ? ? ? ? ?defaults? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0 1
/dev/mmcblk1p1 /data ext4 defaults 0 0
root@nvidia-desktop:/usr/local/lib/python3.8/site-packages# cd ~/
root@nvidia-desktop:~# ls
Desktop
root@nvidia-desktop:/# mkdir /data ?#掛載目錄
root@nvidia-desktop:/# mount /dev/mmcblk1p1 /data??#掛載磁盤(pán)
root@nvidia-desktop:/# df -h?#查看磁盤(pán)信息
Filesystem? ? ? Size? Used Avail Use% Mounted on
/dev/mmcblk0p1? ?14G? ?13G? 136M? 99% /
none? ? ? ? ? ? 1.8G? ? ?0? 1.8G? ?0% /dev
tmpfs? ? ? ? ? ?2.0G? 4.0K? 2.0G? ?1% /dev/shm
tmpfs? ? ? ? ? ?2.0G? ?29M? 2.0G? ?2% /run
tmpfs? ? ? ? ? ?5.0M? 4.0K? 5.0M? ?1% /run/lock
tmpfs? ? ? ? ? ?2.0G? ? ?0? 2.0G? ?0% /sys/fs/cgroup
tmpfs? ? ? ? ? ?397M? ?12K? 397M? ?1% /run/user/120
tmpfs? ? ? ? ? ?397M? ?24K? 397M? ?1% /run/user/1000
/dev/mmcblk1p1? 3.8G? 192K? 3.8G? ?1% /data