返回

在Debian10中挂载子分区

最近要搬家,于是把那块Hikari上的固态盘装到Lolipop上了。 后来急需一个文件,发现那块分区死都挂载不上。

原本我的硬盘(sda)是这么分配的:

  • /dev/sda1 Linux系统盘
  • /dev/sda2 VM直通盘
    • /dev/sda2p1 EFI分区
    • /dev/sda2p2 WinOS

结果现在我只能挂载sda*,sda2p*提示找不到设备。

root@Lolipop:/mnt/120G# mount /dev/sda2p2 ntfs
mount: /mnt/120G/ntfs: special device /dev/sda2p2 does not exist.

那么直接挂载sda2呢?

root@Lolipop:/mnt/120G# mount /dev/sda2 ntfs
mount: /mnt/120G/ntfs: wrong fs type, bad option, bad superblock on /dev/sda2, missing codepage or helper program, or other error.

emmm…. Google上查了一下,发现有类似问题,但是没有解决方案。 google 后来到telegram上问了一下dalao,解决了这个问题。

/dev/mapper

似乎这个地方是专门存放子分区文件系统的 很不巧,ls了一下,我这边并没有相关文件。

root@Lolipop:/dev/mapper# ll 
总用量 0

所以,我们得手动添加

KPartx

kpartx - Create device maps from partition tables

这个软件似乎是专门来创建分区表的 Debian默认没有带,所以得apt装一个 然后使用它的-a参数就可以了

root@Lolipop:/dev/pts# kpartx -a /dev/sda2
root@Lolipop:/dev/pts# fdisk -l
Disk /dev/sda: 111.8 GiB, 120034123776 bytes, 234441648 sectors
Disk model: GLOWAY VAL120GS3
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: 0x7a460d74

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048 117186559 117184512 55.9G 83 Linux
/dev/sda2       117186560 234440703 117254144 55.9G 83 Linux

Disk /dev/mapper/sda2p2: 55.6 GiB, 59665022976 bytes, 116533248 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: 0x73736572

Device                   Boot      Start        End    Sectors   Size Id Type
/dev/mapper/sda2p2-part1      1920221984 3736432267 1816210284   866G 72 unknown
/dev/mapper/sda2p2-part2      1936028192 3889681299 1953653108 931.6G 6c unknown
/dev/mapper/sda2p2-part3               0          0          0     0B  0 Empty
/dev/mapper/sda2p2-part4        27722122   27722568        447 223.5K  0 Empty

Partition table entries are not in disk order.

出现了,sda2p2!

NTFSFix

现在还等什么?赶紧挂载把!

root@Lolipop:/mnt/120G/# mount /dev/mapper/sda2p2 n
The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Falling back to read-only mount because the NTFS partition is in an
unsafe state. Please resume and shutdown Windows fully (no hibernation
or fast restarting.)
Could not mount read-write, trying read-only
^C

等等等等!为什么只能挂只读了?? emm,上次没好好关Windows虚拟机就这样了… 直接ntfsfix!

root@Lolipop:/mnt/120G/ntfs# ntfsfix /dev/mapper/sda2p2
Mounting volume... The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
FAILED
Attempting to correct errors... 
Processing $MFT and $MFTMirr...
Reading $MFT... OK
Reading $MFTMirr... OK
Comparing $MFTMirr to $MFT... OK
Processing of $MFT and $MFTMirr completed successfully.
Setting required flags on partition... OK
Going to empty the journal ($LogFile)... OK
Checking the alternate boot sector... OK
NTFS volume version is 3.1.
NTFS partition /dev/mapper/sda2p2 was processed successfully.

好,现在就可以了!

root@Lolipop:/mnt/120G# mount /dev/mapper/sda2p2 ntfs
root@Lolipop:/mnt/120G# cd ntfs/
root@Lolipop:/mnt/120G/ntfs# ll
总用量 338261
drwxrwxrwx 1 root root         0 5月  26 12:23 '$Recycle.Bin'
drwxrwxrwx 1 root root         0 5月  26 12:30  迅雷下载
-rwxrwxrwx 1 root root    427680 8月  22  2013  bootmgr
-rwxrwxrwx 1 root root         1 6月  18  2013  BOOTNXT
drwxrwxrwx 1 root root         0 5月  26 12:27  disks
lrwxrwxrwx 2 root root        20 8月  22  2013 'Documents and Settings' -> /mnt/120G/ntfs/Users
-rwxrwxrwx 1 root root 345907200 7月  15 18:19  pagefile.sys
drwxrwxrwx 1 root root         0 8月  22  2013  PerfLogs
drwxrwxrwx 1 root root      4096 7月  10 22:01  ProgramData
drwxrwxrwx 1 root root      4096 7月  14 21:49 'Program Files'
drwxrwxrwx 1 root root      4096 6月  15 22:48 'Program Files (x86)'
drwxrwxrwx 1 root root         0 5月  26 12:21  Recovery
drwxrwxrwx 1 root root         0 5月  26 12:20 'System Volume Information'
drwxrwxrwx 1 root root      4096 5月  26 12:23  Users
drwxrwxrwx 1 root root     24576 7月  10 22:07  Windows
Licensed under CC BY-NC-SA 4.0
Made with ❤ By GiriNeko
Built with Hugo
Theme Stack designed by Jimmy