LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2263|回复: 21

【解决】lvm上的系统无法启动。不能自动开启lvm。

[复制链接]
发表于 2009-7-15 11:16:51 | 显示全部楼层 |阅读模式
在移动硬盘上做了个LVM上的Gentoo系统,把根分区也放在LVM里面了。

  内核:hardened-gentoo-2.6.29。应用上fbcondecor补丁。内核配置采用通用配置(以Sabayon的配置为基础,把/usr/share/genkernel/arch/x86/modules_load中指定的模块尽可能地都编译进内核,其中包括dm-mod等)。
生成内核时所用的命令为genkernel --lvm --disklabel --menuconfig all。
名称为2.6.29-hardened(-010)。
  系统中已经安装OpenRC 和 LVM2 两个包。rc-update add lvm boot 已经完成。
  Grub条目后面的参数:slowusb dolvm udev real_root=/dev/LS5000/ROOT

  症状:
完成模块载入后出现:
  1. Loading modules
  2. ......
  3. Activating mdev
  4. Scanning for Volume Groups
  5. Reading all physical volumes. This may take a while...
  6. Activating Volume Groups
  7. Determine root device...
  8. !! Block device /dev/LS5000/ROOT is not a valid root device
  9. !! Could not find the root block device in.
  10. Please specify another value or: press Enter for the same, type "shell" for a shell, or "q" to skip...
  11. root block device():
复制代码
此时如果手动 vgscan && vgchange -a y,再指定/dev/LS5000/ROOT为根分区设备,可以加载 root分区,之后到
  1. * Mounting local filesystem...
  2. mount: special device /dev/LS5000/HOME does not exist.
  3. mount: special device /dev/LS5000/TMP does not exist.
  4. mount: special device /dev/LS5000/USR does not exist.
  5. mount: special device /dev/LS5000/OPT does not exist.
  6. mount: special device /dev/LS5000/VAR does not exist.
  7. * Some local filesystem failed to mount
复制代码
值得留意的时,这期间没有看到/etc/init.d/lvm运行。

  其它信息:
  以下是chroot方式获得的移动硬盘上系统的emerge --info。内核名称对应的是笔记本上的内核。
  1. Portage 2.1.6.13 (hardened/linux/x86/2008.0/desktop, gcc-4.3.3-hardenednopie, glibc-2.9_p20081201-r2, 2.6.29-hardened-007 i686)
  2. =================================================================
  3. System uname: Linux-2.6.29-hardened-007-i686-Genuine_Intel-R-_CPU_T2050_@_1.60GHz-with-gentoo-2.0.1
  4. Timestamp of tree: Sun, 12 Jul 2009 15:45:02 +0000
  5. ccache version 2.4 [enabled]
  6. app-shells/bash: 4.0_p24
  7. dev-lang/python: 2.5.4-r2, 2.6.2-r1
  8. dev-util/ccache: 2.4-r8
  9. sys-apps/baselayout: 2.0.1
  10. sys-apps/openrc: 0.4.3-r3
  11. sys-apps/sandbox: 2.0
  12. sys-devel/autoconf: 2.63-r1
  13. sys-devel/automake: 1.10.2, 1.11
  14. sys-devel/binutils: 2.19.1-r1
  15. sys-devel/gcc-config: 1.4.1
  16. sys-devel/libtool: 2.2.6a
  17. virtual/os-headers: 2.6.30
  18. ACCEPT_KEYWORDS="x86 ~x86"
  19. CBUILD="i486-pc-linux-gnu"
  20. CFLAGS="-O2 -fforce-addr -fomit-frame-pointer -fstack-protector-all -mtune=i686 -pipe"
  21. CHOST="i486-pc-linux-gnu"
  22. CONFIG_PROTECT="/etc /usr/share/config"
  23. CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
  24. CXXFLAGS="-O2 -fforce-addr -fomit-frame-pointer -fstack-protector-all -mtune=i686 -pipe"
  25. DISTDIR="/var/cache/portage/dist"
  26. EMERGE_DEFAULT_OPTS="--with-bdeps y"
  27. FEATURES="buildpkg ccache distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"
  28. GENTOO_MIRRORS="ftp://gentoo.anheng.com.cn/gentoo"
  29. LANG="en_US.UTF-8"
  30. LC_ALL="en_US.UTF-8"
  31. LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  32. LINGUAS="en_US en af am ar as_IN az be be_BY bg bn bn_IN bo br brx bs ca cs csb cy da de de_FR dgo dz el en en_GB en_US en_ZA eo es es_AR es_CR es_ES es_LA et et_EE eu fa fi fo fr fr_CA fy fy_NL ga ga_IE gl gu gu_IN he hi hi_IN hr hsb hu hy id is it ja ka kk km kn kn_IN ko kok ks ku la lb lo lt lv mai mk ml ml_IN mn mni mr mr_IN ms mt nb nb_NO nds ne nl nn nn_NO no nr ns nso oc or_IN pa pa_IN pl pt pt_BR pt_PT ro ru rw sa_IN sat sd se sh sh_YU si sk sl sq sr sr@Latn sr_CS ss st sv sv_SE sw_TZ ta ta_IN te te_IN tg th ti_ER tk tl tn tr ts uk ur_IN ur_PK uz uz@cyrillic ve vi wa xh zh zh_CN zh_HK zh_TW zu"
  33. MAKEOPTS="-j3"
  34. PKGDIR="/var/cache/portage/pkg"
  35. PORTAGE_COMPRESS="lzma"
  36. PORTAGE_COMPRESS_FLAGS="-7"
  37. PORTAGE_CONFIGROOT="/"
  38. PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
  39. PORTAGE_TMPDIR="/var/tmp"
  40. PORTDIR="/var/lib/repo/gentoo"
  41. PORTDIR_OVERLAY="/var/lib/repo/local"
  42. SYNC="rsync://mirror.averse.net/gentoo-portage"
  43. USE="X acl acpi alsa bash-completion berkdb bluetooth branding bzip2 cairo cdr cjk cli cracklib crypt cups dbus doc dri dvd dvdr dvdread emboss encode expat fam fontconfig gdbm gif git gnutls gpm gstreamer hal handbook hardened iconv ieee1394 isdnlog jpeg jpeg2k kde latex ldap libnotify lzo mad midi mikmod mng mp3 mpeg mudflap ncurses networkmanager nls nptl nptlonly ogg openexr opengl openmp pam pcre pdf perl pic png policykit ppds pppd python qt3support qt4 quicktime readline reflection sdl session spell spl ssl startup-notification svg sysfs tcpd tiff truetype unicode urandom usb vim-syntax vorbis webkit win32codecs x86 xcb xcomposite xml xorg xpm xv zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1     emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m     maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en_US en af am ar as_IN az be be_BY bg bn bn_IN bo br brx bs ca cs csb cy da de de_FR dgo dz el en en_GB en_US en_ZA eo es es_AR es_CR es_ES es_LA et et_EE eu fa fi fo fr fr_CA fy fy_NL ga ga_IE gl gu gu_IN he hi hi_IN hr hsb hu hy id is it ja ka kk km kn kn_IN ko kok ks ku la lb lo lt lv mai mk ml ml_IN mn mni mr mr_IN ms mt nb nb_NO nds ne nl nn nn_NO no nr ns nso oc or_IN pa pa_IN pl pt pt_BR pt_PT ro ru rw sa_IN sat sd se sh sh_YU si sk sl sq sr sr@Latn sr_CS ss st sv sv_SE sw_TZ ta ta_IN te te_IN tg th ti_ER tk tl tn tr ts uk ur_IN ur_PK uz uz@cyrillic ve vi wa xh zh zh_CN zh_HK zh_TW zu" USERLAND="GNU" VIDEO_CARDS="apm ark chips cirrus cyrix dummy fbdev glint i128 i740 i810 imstt intel     mach64 mga neomagic nsc nv r128 radeon rendition s3 s3virge savage     siliconmotion sis sisusb tdfx tga trident tseng v4l vesa vga via vmware     voodoo"
  44. Unset: CPPFLAGS, CTARGET, FFLAGS, INSTALL_MASK, PORTAGE_RSYNC_EXTRA_OPTS
复制代码

/etc/fstab
  1. # /etc/fstab: static file system information.
  2. #
  3. # noatime turns off atimes for increased performance (atimes normally aren't
  4. # needed; notail increases performance of ReiserFS (at the expense of storage
  5. # efficiency).  It's safe to drop the noatime options if you want and to
  6. # switch between notail / tail freely.
  7. #
  8. # The root filesystem should have a pass number of either 0 or 1.
  9. # All other filesystems should have a pass number of 0 or greater than 1.
  10. #
  11. # See the manpage fstab(5) for more information.
  12. #
  13. # <fs>            <mountpoint>    <type>    <opts>            <D|P>
  14. # NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
  15. /dev/LS5000/ROOT    /        ext4    noatime            0 1
  16. /dev/LS5000/USR        /usr        ext4    noatime            0 0
  17. /dev/LS5000/HOME    /home        ext4    noatime            0 0
  18. /dev/LS5000/VAR        /var        ext4    noatime            0 0
  19. /dev/LS5000/OPT        /opt        ext4    noatime            0 0
  20. /dev/LS5000/TMP        /tmp        ext4    noatime            0 0
  21. UUID=e73c7183-3ee7-4ded-96f0-ccf937c24be9    /boot        ext4    noatime            0 0
  22. /dev/LS5000/SWAP    none        swap    sw            0 0
  23. /dev/cdrom        /mnt/cdrom    auto    noauto,ro        0 0
  24. #/dev/fd0        /mnt/floppy    auto    noauto            0 0
  25. # glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for
  26. # POSIX shared memory (shm_open, shm_unlink).
  27. # (tmpfs is a dynamically expandable/shrinkable ramdisk, and will
  28. #  use almost no memory if not populated with files)
  29. shm            /dev/shm    tmpfs    nodev,nosuid,noexec    0 0
复制代码

LVM信息
  1.   --- Volume group ---
  2.   VG Name               LS5000
  3.   System ID            
  4.   Format                lvm2
  5.   Metadata Areas        2
  6.   Metadata Sequence No  17
  7.   VG Access             read/write
  8.   VG Status             resizable
  9.   MAX LV                0
  10.   Cur LV                7
  11.   Open LV               1
  12.   Max PV                0
  13.   Cur PV                1
  14.   Act PV                1
  15.   VG Size               65.00 GB
  16.   PE Size               4.00 MB
  17.   Total PE              16640
  18.   Alloc PE / Size       11264 / 44.00 GB
  19.   Free  PE / Size       5376 / 21.00 GB
  20.   VG UUID               klCqce-nCdV-2BLb-UTSX-d0OV-HMaf-ow6nXh
  21.   --- Logical volume ---
  22.   LV Name                /dev/LS5000/ROOT
  23.   VG Name                LS5000
  24.   LV UUID                pA8mkN-sxA5-EQPT-9bXL-fLH8-UhGk-zLvT37
  25.   LV Write Access        read/write
  26.   LV Status              available
  27.   # open                 1
  28.   LV Size                1.00 GB
  29.   Current LE             256
  30.   Segments               1
  31.   Allocation             inherit
  32.   Read ahead sectors     auto
  33.   - currently set to     256
  34.   Block device           251:0
  35.   --- Logical volume ---
  36.   LV Name                /dev/LS5000/USR
  37.   VG Name                LS5000
  38.   LV UUID                JwcpBP-EiRT-mHCs-9TKG-Wrs0-PFCG-5AwWN8
  39.   LV Write Access        read/write
  40.   LV Status              available
  41.   # open                 0
  42.   LV Size                5.00 GB
  43.   Current LE             1280
  44.   Segments               1
  45.   Allocation             inherit
  46.   Read ahead sectors     auto
  47.   - currently set to     256
  48.   Block device           251:1
  49.   --- Logical volume ---
  50.   LV Name                /dev/LS5000/VAR
  51.   VG Name                LS5000
  52.   LV UUID                IiauoL-nIPu-jhrl-lAkr-Ul7d-OhS5-tSW2U0
  53.   LV Write Access        read/write
  54.   LV Status              available
  55.   # open                 0
  56.   LV Size                15.00 GB
  57.   Current LE             3840
  58.   Segments               1
  59.   Allocation             inherit
  60.   Read ahead sectors     auto
  61.   - currently set to     256
  62.   Block device           251:2
  63.   --- Logical volume ---
  64.   LV Name                /dev/LS5000/OPT
  65.   VG Name                LS5000
  66.   LV UUID                12ptTJ-BrYr-KOfz-7uQs-iXaG-5tiC-YsYwjw
  67.   LV Write Access        read/write
  68.   LV Status              available
  69.   # open                 0
  70.   LV Size                5.00 GB
  71.   Current LE             1280
  72.   Segments               1
  73.   Allocation             inherit
  74.   Read ahead sectors     auto
  75.   - currently set to     256
  76.   Block device           251:3
  77.   --- Logical volume ---
  78.   LV Name                /dev/LS5000/TMP
  79.   VG Name                LS5000
  80.   LV UUID                ccRgnV-ReU6-9bLc-bE10-T02f-LRGF-M9BvTG
  81.   LV Write Access        read/write
  82.   LV Status              available
  83.   # open                 0
  84.   LV Size                2.00 GB
  85.   Current LE             512
  86.   Segments               1
  87.   Allocation             inherit
  88.   Read ahead sectors     auto
  89.   - currently set to     256
  90.   Block device           251:4
  91.   --- Logical volume ---
  92.   LV Name                /dev/LS5000/HOME
  93.   VG Name                LS5000
  94.   LV UUID                ixSVyk-1aLP-NBWl-hknv-eGyQ-vtrH-mOL23B
  95.   LV Write Access        read/write
  96.   LV Status              available
  97.   # open                 0
  98.   LV Size                15.00 GB
  99.   Current LE             3840
  100.   Segments               1
  101.   Allocation             inherit
  102.   Read ahead sectors     auto
  103.   - currently set to     256
  104.   Block device           251:5
  105.   --- Logical volume ---
  106.   LV Name                /dev/LS5000/SWAP
  107.   VG Name                LS5000
  108.   LV UUID                82yJL5-CYkW-WVIN-tsdU-5sDL-1WSQ-YotSOE
  109.   LV Write Access        read/write
  110.   LV Status              available
  111.   # open                 0
  112.   LV Size                1.00 GB
  113.   Current LE             256
  114.   Segments               1
  115.   Allocation             inherit
  116.   Read ahead sectors     auto
  117.   - currently set to     256
  118.   Block device           251:6
复制代码

2天了,实在没有精力了。希望能有朋友帮忙解决。十分感谢。

搜索历史:
http://www.google.cn/search?hl=z ... ce+in%22+gentoo+lvm
无有效信息。

官方 LVM2 指南已看过,没有找到相关信息。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
发表于 2009-7-15 16:56:13 | 显示全部楼层
有没有尝试initrd启动?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-7-15 17:30:30 | 显示全部楼层
Post by 亞利艾爾;2006336

生成内核时所用的命令为genkernel --lvm --disklabel --menuconfig all。
必然是initrd启动了……
回复 支持 反对

使用道具 举报

发表于 2009-7-15 17:40:58 | 显示全部楼层
能否贴上 /etc/fstab kernel-config做进一步判断
上次一不小心fstab中多了个noauto,结果老是启动失败
自己没注意排了N久才知道错误

依据你给的信息好像是initrd.img的错误

  1. 在编译完内核并安装好模块之后,将下面这行加入你的/etc/modules.autoload.d/kernel-{KV}中,其中{KV}表示你的内核版本(2.4或2.6),以便在开机时自动加载LVM2:

  2. 代码 2.10: 在/etc/modules.autoload.d/kernel-2.6中添加LVM2模块
  3. # nano -w /etc/modules.autoload.d/kernel-2.6
  4. (添加下面这行)
  5. dm-mod
复制代码

不知道这步做没?(人懒,用着baselayout-1来说事,自己知道相应位置就好了哈~~)

  1. genkernel --lvm2 --menuconfig all
复制代码

没记错genkernel里面没有lvm参数,有的是lvm2的,有点久远,我用genkernel还真没2次,有点记不住
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-7-15 18:05:50 | 显示全部楼层
genkernel有lvm参数。也有lvm2参数,但是已经不推荐(deprecated)了。fstab和kernel config 稍后上传。因为dm-mod已经编译入内核,应该不用加入/etc/conf.d/modules。
  错误最初确实应该发生在initramfs中。
  另外请教一下,加入 --slowusb 有没有用。从第一个“Reading all physical volumes. This may take a while...”可以看出执行了vgscan,但是没有启用,会不会是设备未就绪之类的问题。
回复 支持 反对

使用道具 举报

发表于 2009-7-15 18:18:04 | 显示全部楼层
第一个Reading all physical volumes. This may take a while...
确定是第一个的话那么就是initrd.img的错误,因为你是采用initrd启动,必然2次使用vgscan
dm-mod编入kernel,额你试试modprobe -l|grep dm-mod看看是不是有东西出来,genkerne采用lvm参数是会修改配置的,好像是initrd需要

话说你grub里面有没有加入lvm2的参数

PS:帮助可能不大,我只用过一次initrd,速度太慢了于是直接改做法,所以问题解决方法不太清楚,能给的仅仅是一些知道的信息而已
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-7-15 18:33:52 | 显示全部楼层
LVM信息 fstab 和内核配置上传。感谢回复。

Grub.conf 忘了,大概说下吧。后面是 slowusb dolvm udev real_root=/dev/LS5000/ROOT

刚才加入了--slowusb没有变化。继续等待解答。
回复 支持 反对

使用道具 举报

发表于 2009-7-15 20:11:13 | 显示全部楼层
  1. 在扫描并激活LVM之前,你也许需要先编辑/etc/lvm/lvm.conf文件将一些设备排除在外。因为在默认情况下,LVM2会扫描所有的设备,包括会产生错误信息的光驱。在下面的例子中,我们替换掉了允许扫描所有设备的那行,改为除两个IDE硬盘外,不扫描其他任何设备。

  2. 代码 2.2: 激活LVM
  3. (避免扫描除了硬盘之外的所有其他设备)
  4. # nano -w /etc/lvm/lvm.conf
  5. (查找下面的行)
  6.     filter = [ "a/.*/" ]
  7. (用下面内容来替换,保证只扫描
  8. /dev/hda和/dev/hdb)
  9.     filter = [ "a|/dev/hd[ab]|", "r/.*/" ]
  10. (保存文件并退出nano)
  11. # vgscan
  12.   Reading all physical volumes.  This may take a while...
  13.   No volume groups found
  14. (启用之前创建的卷组)
  15. # vgchange -a y
复制代码

或许这里你改好了,试着在grub后加上root=/dev/ram0

参考Gentoo LVM2安装指南一下看看哪里有问题

话说采用ext4怎么扩建缩小分区大小?好像比较麻烦
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-7-15 20:43:16 | 显示全部楼层
Grub 中的 root=/dev/ram0 是已有的,我忘记加上了。
  如果使用的是上游未作大修改的e2fsprogs的话,我记得Ext2 Ext3 Ext4都是在线可用resize2fs增大分区但是不能在线缩小,离线可增加或缩小。这样就足够了。好像XFS是只能在线改大小,不过我原来也用过XFS,实在不太适合Gentoo。
  关于你指出的地方我会重新再做一次的。另外我打算再试试dm-crypt,可能明天,也可能年底再干了。
回复 支持 反对

使用道具 举报

发表于 2009-7-15 22:33:17 | 显示全部楼层
我这里用的是soft raid+lvm,我是按照官方和wiki上的一个文章安装的。用的是genkernel。
我看了你的安装方法,没有发现什么明显的问题。用的genkernel方法也是
genkernel --install --disklabel --lvm --dmraid all --menuconfig --kernel-config=
我记得一次,也因为kernel升级的缘故,出现莫名其妙的错误,后来重新全新genkernel配置内核一次,就好了。
rc-status boot里边有:mdraid, lvm, device-mapper吗?
grub.conf
title Gentoo Linux 2.6.30-r2
root (hd0,0)
kernel /boot/kernel-genkernel-x86_64-2.6.30-gentoo-r2 root=/dev/ram0 dolvm dodmraid real_root=/dev/md3
initrd /boot/initramfs-genkernel-x86_64-2.6.30-gentoo-r2
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表