天天看點

更改boot分區大小記錄二

問題:

目前更新使用新的鏡像dd到sda磁盤後, 使用partprobe通知核心目錄資訊已經改變,但是對sda3  sda4 格式化解密的時候失敗

+ cryptsetup -q luksFormat /dev/sda3 /tmp/product/.key
+ die 4 'Stage 1, open device sda3 failed.'
+ local retval=4
+ shift
+ '[' 4 == 0 ']'
+ echo ' ** Stage 1, open device sda3 failed.'
 ** Stage 1, open device sda3 failed.
+ cryptsetup -d /tmp/product/.key luksOpen /dev/sda3 xxxxxxx
+ die 4 'Stage 2, open device sda3 failed.'
+ local retval=4
+ shift
+ '[' 4 == 0 ']'
+ echo ' ** Stage 2, open device sda3 failed.'
 ** Stage 2, open device sda3 failed.
+ mkfs.ext4 -t ext4 -L xxxxxx /dev/mapper/xxxxx
+ die 1 'Stage 3, open device sda3 failed.'
+ local retval=1
+ shift
+ '[' 1 == 0 ']'
+ echo ' ** Stage 3, open device sda3 failed.'
 ** Stage 3, open device sda3 failed.      
openat(AT_FDCWD, "/dev/sda2", O_RDONLY) = 7
fstat(7, {st_mode=S_IFBLK|0600, st_rdev=makedev(8, 2), ...}) = 0
ioctl(7, BLKGETSIZE64, [128849018880])  = 0      

目前看到:openat, 這是啥??

First, openat() allows an application to avoid race conditions that could occur when using open(2) to open files in directories other than the current working directory. These race conditions result from the fact that some component of the directory prefix given to open(2) could be changed in parallel with the call to open(2). Such races can be avoided by opening a file descriptor for the target directory, and then specifying that file descriptor as the dirfd argument of openat().

Second, openat() allows the implementation of a per-thread “current working directory”, via file descriptor(s) maintained by the application. (This functionality can also be obtained by tricks based on the use of /proc/self/fd/dirfd, but less efficiently.)      

   引入openat是友善一個程序内的各線程可擁有不同的目前目錄,傳統的chdir會影響整個程序,而使用openat隻需要每個線程在初始化時打開一個目錄(調用open),然後就可以以openat在“目前目錄”操作檔案了,如:

int dirfd = open("/var"); // 相當于chdir到“/var”

int filefd = openat(dirfd, "thread1"); // 在/var目錄下打開“thread1”檔案

那為什麼會出現上述錯誤呢?

隻能調試腳本:重新制作initrd 加入調試

目前可以直接看到問題原因: 磁盤分區時出現問題, 第一個分區的開始block 不是從1 開始;但是後面安裝的時候安裝腳本出現問題

更改boot分區大小記錄二
0
+ cryptsetup -q luksFormat /dev/sda3 /tmp/product/.key
+ die 4 'Stage 1, open device sda3 failed.'
+ local retval=4
+ shift
+ '[' 4 == 0 ']'
+ echo ' ** Stage 1, open device sda3 failed.'
 ** Stage 1, open device sda3 failed.
+ exit 4
sh-4.2# 
sh-4.2#  cryptsetup -q luksFormat /dev/sda3 /tmp//.key
Device /dev/sda3 doesn't exist or access denied.
sh-4.2#  cryptsetup -q luksFormat /dev/sda3 /tmp//.key
Device /dev/sda3 doesn't exist or access denied.
sh-4.2# 
sh-4.2# ls /dev/sd
sda   sda1  sda2  sdb   sdb1  sdb2  sdb3  sdb4  sdb5  
sh-4.2# ls /dev/sd
sda   sda1  sda2  sdb   sdb1  sdb2  sdb3  sdb4  sdb5  
sh-4.2# pa        
parted     partprobe  passwd     patch      
sh-4.2# pa
parted     partprobe  passwd     patch      
sh-4.2# fdisk  -l

Disk /dev/sda: 8019 MB, 8019099648 bytes
16 heads, 32 sectors/track, 30590 cylinders
Units = cylinders of 512 * 512 = 262144 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               5         404      102400  83 Linux
/dev/sda2             405         800      101376  83 Linux      

繼續閱讀