日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

linux内核不识别分区,ubuntu14.04无法识别树莓派SD卡问题

發(fā)布時(shí)間:2023/12/9 linux 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux内核不识别分区,ubuntu14.04无法识别树莓派SD卡问题 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

raspberry pi 樹(shù)莓派有兩種安裝方式,鏡像安裝和noobs安裝。入門(mén)用戶通常按照官方教程選擇簡(jiǎn)單的noobs安裝方式,一般順序:格式化sd卡,拷貝noobs鏡像,然后將sd卡插入樹(shù)莓派卡槽,連接視頻線,加電引導(dǎo)并配置。(說(shuō)明樹(shù)莓派固件功能還比較豐富,已經(jīng)可以識(shí)別文件系統(tǒng)了)。

有一天我想備份一下16G的樹(shù)莓派sd卡,于是掉電后取出sd,連在我的ubuntu 14.04系統(tǒng)上,這時(shí)候問(wèn)題來(lái)了,ubuntu掛載不成功!fdisk命令只能看到樹(shù)莓派的一個(gè)分區(qū),而且無(wú)法掛載和讀寫(xiě)!sd卡取下來(lái)再放回樹(shù)莓派,又是好的,啟動(dòng)正常。查看樹(shù)莓派分區(qū)如下:

1.樹(shù)莓派分區(qū)分析:

p1分區(qū)為主分區(qū),帶有noobs鏡像的16G的sd第一次引導(dǎo)啟動(dòng)后,被安裝程序?qū)⒎謪^(qū)壓縮到了800m左右,這個(gè)大小剛好差不多也是noobs鏡像的大小。

p2分區(qū)為擴(kuò)展分區(qū),占用了剩下的絕大部分空間中的14G。p5和p6是擴(kuò)展分區(qū)中的兩個(gè)邏輯分區(qū),p5為boot分區(qū),只有60m左右,p6就是整個(gè)raspbian的操作系統(tǒng)分區(qū)啦,14G左右。

p3分區(qū)為主分區(qū),只有30m左右,非常小,里面儲(chǔ)存了noobs安裝過(guò)程中了幾個(gè)配置文件。

因此,樹(shù)莓派分區(qū)表是沒(méi)有問(wèn)題的,用dd命令打印出前512字節(jié)的MBR,對(duì)照分析一切正常,否則樹(shù)莓派不可能啟動(dòng)。難道樹(shù)莓派的debian7和ubuntu存在什么不兼容嗎?

2.ubuntu錯(cuò)誤打印:

把sd卡又重新插回ubuntu上,這次看了一下dmsg系統(tǒng)打印:

[ 338.332373] usb 1-1: new high-speed USB device number 5 using ehci-pci

[ 338.467637] usb 1-1: New USB device found, idVendor=14cd, idProduct=6700

[ 338.467651] usb 1-1: New USB device strings: Mfr=1, Product=3, SerialNumber=2

[ 338.467659] usb 1-1: Product: USB 2.0 SD/MMC READER

[ 338.467666] usb 1-1: Manufacturer: SDMMC M121

[ 338.467671] usb 1-1: SerialNumber: 834341670014

[ 338.469554] usb-storage 1-1:1.0: USB Mass Storage device detected

[ 338.469782] scsi host10: usb-storage 1-1:1.0

[ 339.470612] scsi 10:0:0:0: Direct-Access USB 2.0 SD/MMC Reader PQ: 0 ANSI: 0 CCS

[ 339.471488] sd 10:0:0:0: Attached scsi generic sg3 type 0

[ 339.472434] sd 10:0:0:0: [sdc] 31116288 512-byte logical blocks: (15.9 GB/14.8 GiB)

[ 339.473384] sd 10:0:0:0: [sdc] Write Protect is off

[ 339.473396] sd 10:0:0:0: [sdc] Mode Sense: 03 00 00 00

[ 339.474175] sd 10:0:0:0: [sdc] No Caching mode page found

[ 339.474188] sd 10:0:0:0: [sdc] Assuming drive cache: write through

[ 339.493264] sdc: [CUMANA/ADFS] sdc1 [ADFS] sdc1

[ 339.497803] sd 10:0:0:0: [sdc] Attached SCSI removable disk

從高亮的第16行可以看出,ubuntu已經(jīng)識(shí)別樹(shù)莓派sd卡為sdc磁盤(pán)設(shè)備,但是只解析到了第一個(gè)分區(qū)sdc1,而且還打印了[CUMANA/ADFS],是什么鬼?搜索一下就明白了,原來(lái)ADFS是Risc OS的文件系統(tǒng),可為什么明明是fat分區(qū)ubuntu卻識(shí)別錯(cuò)了呢?

3.原因分析:

在英文網(wǎng)站一陣猛搜:

after NOOBS has done it's initial first-boot resizing, the MBR itself and the first partition never get modified. It's only files on the SETTINGS partition (mmcblk0p3) and all the logical partitions within the extended partition (mmcblk0p2) that get written to.

So even if a 'bad write' wiped out the entirety of mmcblk0p2 and mmcblk0p3, then NOOBS itself (stored on the mmcblk0p1 RECOVERY partition and never written to) would still be bootable, and allow you to install a fresh OS.

As already (partially) mentioned, on a post-initial-boot NOOBS card, there's both an MBR partition table at bytes 1-512 inclusive, and an ADFS partition table at bytes 513-10240 inclusive (the 9728 bytes of riscos-boot.bin ). Both partition tables are equally valid, with the MBR table describing the 'regular' linux partitions (Raspbian, OSMC, etc. as well as RECOVERY and SETTINGS), and the ADFS table describing the RISCOS partition (regardless of whether it's been installed yet or not). RISCOS doesn't understand MBR partitions, and so it always installs to a fixed location on the SD card.

And as the comment at https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/block/partitions/check.c#n56; explains, the kernel partition-checking code looks for the Acorn partition table before looking for the msdos (MBR) partition table. Hence the cause of the problem as initially reported :-S

原來(lái),樹(shù)莓派noobs安裝第一次啟動(dòng)后,除了寫(xiě)入mbr主引導(dǎo)信息之外,還額外寫(xiě)入了RiscOS的引導(dǎo)程序riscos-boot.bin,兩個(gè)同時(shí)有效,這樣做是為了防止sd卡分區(qū)丟失無(wú)法啟動(dòng),那么riscos/Acorn blob就還能工作和引導(dǎo)(樹(shù)莓派真是用心良苦)。

但是,所有新的linux內(nèi)核都有個(gè)問(wèn)題就是會(huì)優(yōu)先搜索和檢測(cè)RiscOS blob,然后才是mbr引導(dǎo)分區(qū)。所以就用了錯(cuò)誤的方式的識(shí)別sd卡導(dǎo)致其無(wú)法掛載。相關(guān)討論鏈接原文:

4.解決辦法:

1.第一個(gè)主分區(qū)偏移0xdd0的地方是risc引導(dǎo)信息,用dd命令填0覆蓋;

2.找到分區(qū)的起始偏移地址,然后強(qiáng)制掛載,例如:

sudo mount /dev/sdc /mnt/ -o offset=$((385024*512))

3. 內(nèi)核bug修復(fù)記錄顯示:

This bug was fixed in the package linux - 3.19.0-26.28

---------------

linux (3.19.0-26.28) vivid; urgency=low

[ Tim Gardner ]

* [Config] ACORN_PARTITION=n

- LP: #1453117

也就是說(shuō),代號(hào)vivid的ubuntu15.10已經(jīng)修復(fù)了這個(gè)bug,最簡(jiǎn)單就是升級(jí)到15.10或者16.04吧!

總結(jié)

以上是生活随笔為你收集整理的linux内核不识别分区,ubuntu14.04无法识别树莓派SD卡问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。