赞
踩
# 导入public key rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org #Centos8 yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm #Centos7 yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm # 备份当前repo文件 cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.back # 下载ali cloud centos 源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # 安装扩展仓库 wget -O /etc/yum.repos.d/epel-7.repo wget http://mirrors.aliyun.com/repo/epel-7.repo #Centos8 wget http://mirrors.aliyun.com/repo/Centos-8.repo -O /etc/yum.repos.d/Centos-8.repo # 下载163 centos 源 wget http://mirrors.163.com/repo/Centos-8.repo -O /etc/yum.repos.d/Centos-8.repo # Fedora: wget http://mirrors.aliyun.com/repo/fedora.repo -O /etc/yum.repos.d/fedora.repo 或者 wget https://mirrors.163.com/.help/fedora-updates-163.repo wget https://mirrors.163.com/.help/fedora-163.repo yum clean all yum makecache yum update #yum源码包 yum install yum-utils -y # download rpm yumdownloader --downloadonly --downloaddir=/tmp bison # download source yumdownloader --source bison # save to xx.tar.gz rpm2cpio bison-3.7.6-3.fc35.src.rpm| cpio -id #compile make //查询 rpm packages dnf -q provides lib{babeltrace,bpf}-devel
# 7z # apt install -y p7zip-full #curl yum -y install curl #python3 dnf install python3 #cmake yum install cmake #llvm yum install llvm lld lldb dnf install clang #wine yum install wine #apci # yum install acpica-tools rpm -ivh http://mirrors.163.com/centos/8/BaseOS/x86_64/os/Packages/acpica-tools-20180629-3.el8.x86_64.rpm #busybox rpm -ivh http://rpmfind.net/linux/fedora/linux/releases/33/Everything/x86_64/os/Packages/b/busybox-1.32.0-2.fc33.x86_64.rpm #numactl yum install numactl # tune yum install tune
yum install -y dosfstools
yum install -y grub2-efi-x64-modules.noarch
yum install -y efibootmgr
yum -y install gcc gcc-c++
yum install -y ncurses ncurses-devel
yum install -y elfutils-libelf-devel openssl-devel dwarves make flex bison
yum install -y glibc-static
yum -y install gcc gcc-c++ git python3 nasm iasl libuuid-devel qemu
dnf --enablerepo=powertools install dwarves
或者
yum install -y gcc gcc-c++ git python3 nasm iasl libuuid-devel dosfstools ncurses ncurses-devel elfutils-libelf-devel openssl-devel dwarves make flex bison glibc-static
yum groupinstall "GNOME Desktop" "Graphical Administration Tools" ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target 4. 編譯Linux kernel //下载linux-4.18.1.tar.xz wget https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.18.1.tar.gz //解压linux-4.18.1.tar.xz tar xvf linux-4.18.1.tar.gz -C /usr/src //切换内核解压目录下 cd /usr/src/linux-4.18.1 //制作.config # make mrproper cp /boot/config-4.6.3-fc32.x86_64 /usr/src/linux-4.18.1/.config make olddefconfig 或者 make menuconfig //编译kernel make all //安装模块/内核 make modules_install make install reboot
CSDN=/root/csdn TOP_BUILD=$CSDN/build mkdidr -p $TOP_BUILD cd $CSDN #下载解压busybox源码 wget https://busybox.net/downloads/busybox-1.26.2.tar.bz2 --no-check-certificate tar xjf busybox-1.26.2.tar.bz2 #生成.config cd $CSDN/busybox-1.26.2 mkdir -pv $TOP_BUILD/obj/busybox-x86 make O=$TOP_BUILD/obj/busybox-x86 defconfig make O=$TOP_BUILD/obj/busybox-x86 menuconfig sed -i "s/.*CONFIG_STATIC.*/CONFIG_STATIC=y/" $TOP_BUILD/obj/busybox-x86/.config (或者Busybox Settings ---> Build BusyBox as a static binary (no shared libs).) cd $TOP_BUILD/obj/busybox-x86 make -j2 make install mkdir -pv $TOP_BUILD/initramfs/x86-busybox cd $TOP_BUILD/initramfs/x86-busybox mkdir -pv {bin,dev/tty0,sbin,etc,proc,sys/kernel/debug,usr/{bin,sbin},lib,lib64,mnt/root,root} #copy 编译生成的busybox cp -av $TOP_BUILD/obj/busybox-x86/_install/* $TOP_BUILD/initramfs/x86-busybox cp -av /dev/{null,console,tty,sda1} $TOP_BUILD/initramfs/x86-busybox/dev/ #创建init文件 cat > $TOP_BUILD/initramfs/x86-busybox/init < EOF #!/bin/sh mount -t proc none /proc mount -t sysfs none /sys #mount -t debugfs none /sys/kernel/debug mdev -s echo -e "\nBoot took $(cut -d' ' -f1 /proc/uptime) seconds\n" #exec /bin/sh exec /sbin/init EOF chmod +x $TOP_BUILD/initramfs/x86-busybox/init #创建 ./etc/passwd与 ./etc/group echo "root::0:0:root:/:/bin/sh" > ./etc/passwd touch ./etc/group #创建 ./etc/inittab cat > ./etc/inittab << EOF ::sysinit:/etc/rc.d/rcS ::respawn:/sbin/getty -n -l /bin/sh ttyS0 115200 ::respawn:/bin/cttyhack /bin/sh ::shutdown:/bin/umount -a -r ::shutdown:/sbin/swapoff -a ::restart:/sbin/init EOF #创建 . ./etc/fstab cat > ./etc/fstab << EOF proc /proc proc defaults 0 0 sys /sys sysfs defaults 0 0 none /dev devtmpfs defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 none /dev/pts devpts defaults 0 0 EOF #创建 . ./etc/hostname echo "busybox_csdn" > ./etc/hostname #创建 ./etc/rc.d/rcS mkdir -p ./etc/rc.d/ && touch ./etc/rc.d/rcS echo '#!/bin/sh /bin/hostname -F /etc/hostname /bin/mount /proc # We need to do this before remounting root /bin/mount /sys /bin/mount -o remount,rw / # Remount read-write /bin/mount /dev /bin/mkdir /dev/shm /bin/mkdir /dev/pts /bin/mount -a # Mount all filesystems in fstab, except those marked with 'noauto' /sbin/ifconfig lo 127.0.0.1 # Setup loopback interface for network (if you have networking in your kernel) #/sbin/inetd # If you want inetd to run #/sbin/telnetd # If you want standalone telnetd to run -- incompatible with inetd it seems ' > ./etc/rc.d/rcS chmod +x ./etc/rc.d/rcS #创建 tty设备文件 mknod ./dev/tty1 c 4 1 mknod ./dev/tty2 c 4 2 mknod ./dev/tty3 c 4 3 mknod ./dev/tty4 c 4 4 ls -l ./dev/tty[0-9] #打包initramfs cd $TOP_BUILD/initramfs/x86-busybox find . -print0 | cpio --null -ov --format=newc | gzip -9 > $TOP_BUILD/obj/initramfs-busybox-x86.cpio.gz #对U盘前500MB清零 dd if=/dev/zero of=/dev/sdb bs=1M count=512; #对U盘(/dev/sdb)进行分区 gdisk /dev/sdb GPT fdisk (gdisk) version 0.8.10 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): p Disk /dev/sdb: 60062500 sectors, 28.6 GiB Logical sector size: 512 bytes Disk identifier (GUID): 2280F128-40B9-44EF-8972-59E8AA2C1DD3 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 60062466 Partitions will be aligned on 2048-sector boundaries Total free space is 60062433 sectors (28.6 GiB) Number Start (sector) End (sector) Size Code Name Command (? for help): n Partition number (1-128, default 1): First sector (34-60062466, default = 2048) or {+-}size{KMGTP}: Last sector (2048-60062466, default = 60062466) or {+-}size{KMGTP}: 110MiB Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): EF00 Changed type of partition to 'EFI System' Command (? for help): p Disk /dev/sdb: 60062500 sectors, 28.6 GiB Logical sector size: 512 bytes Disk identifier (GUID): 2280F128-40B9-44EF-8972-59E8AA2C1DD3 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 60062466 Partitions will be aligned on 2048-sector boundaries Total free space is 59839200 sectors (28.5 GiB) Number Start (sector) End (sector) Size Code Name 1 2048 225280 109.0 MiB EF00 EFI System Command (? for help): n Partition number (2-128, default 2): First sector (34-60062466, default = 227328) or {+-}size{KMGTP}: Last sector (227328-60062466, default = 60062466) or {+-}size{KMGTP}: 400MiB Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): 8300 Changed type of partition to 'Linux filesystem' Command (? for help): p Disk /dev/sdb: 60062500 sectors, 28.6 GiB Logical sector size: 512 bytes Disk identifier (GUID): 2280F128-40B9-44EF-8972-59E8AA2C1DD3 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 60062466 Partitions will be aligned on 2048-sector boundaries Total free space is 59247327 sectors (28.3 GiB) Number Start (sector) End (sector) Size Code Name 1 2048 225280 109.0 MiB EF00 EFI System 2 227328 819200 289.0 MiB 8300 Linux filesystem Command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT) to /dev/sdb. Warning: The kernel is still using the old partition table. The new table will be used at the next reboot. The operation has completed successfully. [root@localhost ~]# #对U盘(/dev/sdb)进行格式化 fdisk -l /dev/sdb mkfs.vfat -F 32 -s 2 /dev/sdb1 mkfs.ext3 /dev/sdb2 #对U盘安装bootloader这里用grub tool,也可以使用LILO mkdir -p /mnt/boot/efi && mkdir -p /mnt/boot/grub mount /dev/sdb2 /mnt/ && mount /dev/sdb1 /mnt/boot/efi grub2-install --root-directory=/mnt/ --target=x86_64-efi /dev/sdb #创建EFI/BOOT/bootx64.efi,确保UEFI可以boot mkdir -p /mnt/boot/efi/EFI/BOOT cp /mnt/boot/efi/EFI/centos/grubx64.efi /mnt/boot/efi/EFI/BOOT/bootx64.efi # copy 本机的kernel 镜像(也可以自己编译) cp /boot/vmlinuz-3.10.0-514.el7.x86_64 /mnt/ #copy上面编译的busybox initramfs cp /root/csdn/build/obj/initramfs-busybox-x86.cpio.gz /mnt/ # 获取主分区的UUID用来填充grub.cfg lsblk -f # Get UUID # In Grub UI,ls -l 8006ca13-d59a-4a28-8b02-e8c8eed498b4 mount /dev/sdb2 /mnt/ mount /dev/sdb1 /mnt/boot/efi cp /boot/vmlinuz-3.10.0-514.el7.x86_64 /mnt/ cp /root/csdn/build/obj/initramfs-busybox-x86.cpio.gz /mnt/ echo 'menuentry 'csdn-kernel-3.10.0-514.el7.x86_64' --class gnu-linux --class gnu --class os { insmod gzio insmod part_gpt search --no-floppy --fs-uuid --set 8006ca13-d59a-4a28-8b02-e8c8eed498b4 echo 'Loading csdn kernel 3.10.0 ...' linux /vmlinuz-3.10.0-514.el7.x86_64 rw init=/bin/sh console=ttyS0,9600n8 console=tty0 consoleblank=0 earlyprintk=ttyS0,9600 kgdboc=kbd,ttyS0 loglevel=7 echo 'Loading initial ramdisk busybox ...' initrd /initramfs-busybox-x86.cpio.gz }' > /mnt/boot/efi/EFI/centos/grub.cfg echo 'menuentry 'csdn-kernel-3.10.0-514.el7.x86_64' --class gnu-linux --class gnu --class os { insmod gzio insmod part_gpt search --no-floppy --fs-uuid --set 8006ca13-d59a-4a28-8b02-e8c8eed498b4 echo 'Loading csdn kernel 3.10.0 ...' linux /vmlinuz-3.10.0-514.el7.x86_64 rw init=/bin/sh console=ttyS0,9600n8 console=tty0 consoleblank=0 earlyprintk=ttyS0,9600 kgdboc=kbd,ttyS0 loglevel=7 echo 'Loading initial ramdisk busybox ...' initrd /initramfs-busybox-x86.cpio.gz }' > /mnt/boot/grub2/grub.cfg cat /mnt/boot/efi/EFI/centos/grub.cfg umount /dev/sdb1 umount /dev/sdb2 dd if=/dev/sdb bs=512 count=819201 of=./csdn_busybox2.img 7za a csdn_busybox2.7z csdn_busybox2.img scp root@192.168.1.18:/root/csdn_busybox2.7z . # QEMU 启动busybox chcp 65001 && "C:\Program Files\qemu\qemu-system-x86_64.exe" -bios "OVMF.fd" -M "pc" -m 256 -cpu "qemu64" -boot order=dc -serial stdio -hda csdn_busybox2.img chcp 65001 && "C:\Program Files\qemu\qemu-system-x86_64.exe" -bios "OVMF.fd" -M "pc" -m 256 -cpu "qemu64" -boot order=dc -serial stdio -hda D:\share\centos7.img chcp 65001 && "C:\Program Files\qemu\qemu-system-x86_64.exe" -bios "OVMF.fd" -M "pc" -m 256 -cpu "qemu64" -boot order=dc -serial stdio -usbdevice disk:HDD_BOOT.img
make -C /root/edk2/BaseTools/Source/C ./OvmfPkg/build.sh -D DEBUG_ON_SERIAL_PORT # 在Centos下制作虚拟盘 # 新建HDD_BOOT.img的空文件 qemu-img create -f raw HDD_BOOT.img 64M # 格式化img文件 mkfs.vfat HDD_BOOT.img # 将文件加载到设备文件 losetup /dev/loop8 HDD_BOOT.img #新建挂载目录 mkdir -p /mnt/hello #将设备挂载到目录 mount /dev/loop8 /mnt/hello cp ./Build/OvmfX64/DEBUG_GCC48/X64/HelloWorldPci.efi /mnt/hello cp ./Build/OvmfX64/DEBUG_GCC48/X64/DumpHobs.efi /mnt/hello # 将efi文件回写到 HDD_BOOT.img umount /dev/loop8 losetup -d /dev/loop8 qemu-system-x86_64 -bios ./Build/OvmfX64/DEBUG_GCC48/FV/OVMF.fd \ -serial stdio -usb -drive if=none,format=raw,id=disk1,file=HDD_BOOT.img \ -device usb-storage,drive=disk1
sed 's/quiet/console=ttyS1,9600 loglevel=8/' -i /etc/default/grub grub2-mkconfig -o /boot/grub2/grub.cfg grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg reboot
gdisk ./centos7.img
>t
losetup --offset 1MiB --sizelimit 1024MiB /dev/loop7 ./centos7.img
losetup --offset 1024MiB /dev/loop8 ./centos7.img
mount /dev/loop8 /mnt2
mount /dev/loop7 /mnt2/boot/efi
grub2-install --efi-directory=/mnt2/ --target=x86_64-efi ./centos7.img
echo 'PasswordAuthentication yes
PermitRootLogin yes
AllowUsers root' >> /etc/ssh/sshd_config
service sshd restart
sed '/LANG=/cLANG="en_US.UTF-8"' -i /etc/locale.conf
export proxy="http://xxx.com:123(实际定义Port)" export http_proxy=$proxy export https_proxy=$proxy echo 'sslverify=0' >> /etc/dnf/dnf.conf echo ' export HTTP_PROXY="http://xxx.com:123(实际定义Port)/" export HTTPS_PROXY="https://xxx.com:912/" export http_proxy="http://xxx.com:123(实际定义Port)/" export https_proxy="https://xxx.com:912/" export FTP_PROXY="http://xxx.com:21/" use_proxy=on ' >> /etc/profile.d/proxy.sh chmod +x /etc/profile.d/proxy.sh echo ' proxy="http://xxx.com:123(实际定义Port)/" ' >> /etc/dnf/dnf.conf echo ' proxy="http://xxx.com:123(实际定义Port)/" ' >> /etc/yum.conf //fix ssl errors echo ' proxy=http://proxy-xxxx.com:xxx/ ' >> .curlrc
#轉換 vmdk为 img 文件 "C:\Program Files\qemu\qemu-img.exe" convert Fedora-single.vmdk Fedora-single.img #轉換 img為vmdk文件 "C:\Program Files (x86)\VMware\VMware Workstation\vmware-vdiskmanager.exe" -r ".\Fedora 64 位.vmdk" -t 0 ".\Fedora-single.vmdk" # 轉換img為vdi "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" convertfromraw -format VDI Fedora-single.img Fedora-single.vdi "C:\Program Files\qemu\qemu-img.exe" convert -f raw -O vdi fwts-live-22.03.00-x86_64.img fwts-live-22.03.00-x86_64.vdi # 轉換vdi為img "C:\Program Files\qemu\qemu-img.exe" convert -f vdi Fedora-single.vdi Fedora-single2.img "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonehd Fedora-single.vdi Fedora-single.raw --format RAW # 轉換vmdk為vdi "C:\Program Files\qemu\qemu-img.exe" convert -f vmdk -O vdi Fedora-single.vmdk Fedora-single.vmdk.vdi "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonehd Fedora-single.vmdk Fedora-single.vdi --format VDI #轉換 vdi為 qcow2 "C:\Program Files\qemu\qemu-img.exe" convert -f vdi Fedora-single.vdi -O qcow2 Fedora-single2.qcow2 #轉換 vdi為 vmdk "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonehd Fedora-single.vdi Fedora-single.vmdk --format VMDK #轉換 vdi為 VHD "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonehd Fedora-single.vdi Fedora-single.vhd --format VHD # 設置鏡像文件UUID "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showmediuminfo Fedora-single.vdi "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands sethduuid Fedora-single.vdi d8f845dc-1362-433a-8d56-0ee196fa4f6d # VDI 文件扩容 1) "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd Fedora-single.vdi --resize 11920 2) "C:\Program Files\qemu\qemu-img.exe" resize Fedora-single.img +10G "C:\Program Files\qemu\qemu-img.exe" convert -f raw -O vdi Fedora-single.img Fedora-single.vdi
cp /lib/systemd/system/serial-getty@.service /lib/systemd/system/serial-getty@.service.bak sed '/ExecStart=-/cExecStart=-/sbin/agetty -a root -8 -L %I 9600 $TERM' -i /lib/systemd/system/serial-getty@.service
//编辑开机自启动脚本
vim /etc/rc.local
//设置开机自启动权限
chmod +x /etc/rc.d/rc.local
# 方法一: 在 linux16 参数这行的最后面追加“rd.break mount -o remount,rw /sysroot chroot /sysroot passwd touch /.autorelabel exit reboot # 方法二: //按e 进入编辑界面如下把ro改为?“rw init=/sysroot/bin/sh”. 然后 “Ctrl+x”启动 //依次输入以下命令进行root密码修改,修改完成之后退出 强制重启即可。 chroot /sysroot/passwd passwd touch /.autorelabel exit reboot
wget https://ftp.gnu.org/gnu/grub/grub-2.04.tar.xz
tar xvf grub-2.04.tar.xz
# ./configure && make && make install
fdisk -u /dev/sdb
Command (m for help): p
Command (m for help): d
Selected partition 2
Command (m for help): n
Partition number (1-4): 2
First sector (195313-25165823, default 195313): 195313 # must align as original
Command (m for help): w
e2fsck -f /dev/sdb2
resize2fs /dev/sdb2
# sdb3-> 主os的第三塊分區, sdc 為guest os
dd if=/dev/sdc of=/dev/sdb3 status=progress bs=10M conv=noerror
wget https://ftp.gnu.org/gnu/gcc/gcc-7.5.0/gcc-7.5.0.tar.xz 或者 wget https://ftp.gnu.org/gnu/gcc/gcc-7.4.0/gcc-7.4.0.tar.xz tar xf gcc-7.5.0.tar.xz cd gcc-7.5.0 ./contrib/download_prerequisites sed 's/ftp:\/https:\//' ./contrib/download_prerequisites cd .. mkdir gcc-7.5.0-build cd gcc-7.5.0-build ../gcc-7.5.0/configure --enable-languages=c,c++ --disable-multilib make sudo make install export PATH=/usr/local/bin:$PATH export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH
# yum -y install tigervnc-server # vncserver //设置密码 # vncpasswd //设置密码 # echo "gnome-session &" >> /root/.vnc/xstartup #yum install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal //fix the terminal could not open # echo ' gnome-panel & gnome-settings-daemon & metacity & nautilus & gnome-terminal & gnome-session &' >> /root/.vnc/xstartup # echo ' #!/bin/bash /sbin/iptables -I INPUT 1 -p TCP --dport 5901:5910 -j ACCEPT vncserver -geometry 1920x1080' >> vnc.sh # echo -e 'VNCSERVERS="1:root" VNCSERVERARGS[1]="-geometry 1024x768"' >> /etc/sysconfig/vncservers
# lvs // 查看VG
# lvcreate -L 30.00g -n lvubutnu fedora_intel-obmc
# mkfs.ext4 /dev/fedora_intel-obmc/lvubutnu
# mount /dev/fedora_intel-obmc/lvubutnu /mnt
# lvcreate -L 30.00g -n lvkernel fedora
# mkfs.ext4 /dev/fedora/lvkernel
# mount /dev/fedora/lvkernel /mnt
# qemu-img create -f qcow Ubuntu20.img 20G # qemu-kvm -enable-kvm -boot d -cdrom ubuntu-20.04-desktop-amd64.iso -hda Ubuntu20.img -m 8192 # qemu-kvm -m 8192 -enable-kvm Ubuntu20.img echo 'qemu-kvm -enable-kvm -boot d -cdrom ubuntu-20.04-desktop-amd64.iso -hda Ubuntu20.img -m 8192' >> insatll_ubuntu.sh chmod +x insatll_ubuntu.sh echo ' #!/bin/bash qemu-kvm -L /mnt/img -m 8192 -hda /mnt/img/Ubuntu20.img -enable-kvm' > /mnt/img/setupvm.sh chmod +x /mnt/img/setupvm.sh echo ' #!/bin/bash mount /dev/fedora_intel-obmc/lvubutnu /mnt /mnt/img/setupvm.sh > /dev/null 2>&1 &' >> startvm.sh chmod +x startvm.sh # lsusb --> Bus 001 Device 006: ID 0951:16a2 Kingston Technology DTR30G2 # qemu-kvm -m 8192 -enable-kvm Ubuntu20.img -usbdevice host:xxx:xxx
#CGDB安装 [root@localhost ~]# wget https://github.com/cgdb/cgdb/archive/v0.7.0.tar.gz [root@localhost ~]# tar xf v0.7.0.tar.gz [root@localhost ~]# cd cgdb-0.7.0/ [root@localhost cgdb-0.7.0]# ./autogen.sh [root@localhost cgdb-0.7.0]# ./configure --prefix=${HOME}/cgdb [root@localhost cgdb-0.7.0]# make && make install 或者 #yum install cgdb -y # Install qemu yum install qemu-kvm qemu-img -y ctrl-alt-f toggle full screen ctrl-alt-n switch to virtual console 'n' ctrl-alt toggle mouse and keyboard grab #GDB debug kernel cd /root/linux-4.9.153 # cgdb vmlinux (gdb) target remote :1234 Remote debugging using :1234 native_safe_halt () at ./arch/x86/include/asm/irqflags.h:57 (gdb) b register_filesystem Breakpoint 1 at 0xffffffff81257dd0: file fs/filesystems.c, line 70. (gdb) c Continuing. Breakpoint 1, register_filesystem (fs=0xffffffffa00a0ac0) at fs/filesystems.c:70 (gdb) p fs->name $1 = 0xffffffffa0095cc0 "ext3"
#grubby --update-kernel=ALL --args="console=tty0 console=ttyS0,115200n8 earlyprintk=ttyS0,115200 loglevel=9 "
#sed '/ONBOOT=/cONBOOT=yes' -i /etc/sysconfig/network-scripts/ifcfg-ens3
#设置默认启动kernel
grubby --set-default /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64
grubby --set-default-index=0(以实际序列为准)
# Refer the below guide https://uefi.org/specs/ACPI/6.4/18_ACPI_Platform_Error_Interfaces/error-injection.html # Inejct CE errors dmesg -C modprobe einj cd /sys/kernel/debug/apei/einj echo 0x8 > error_type # memory CE echo 0x12345677 > param1 #any system address echo 0xfffffffffffff000 > param2 #13->f,3->0 echo 1 > error_inject # Inejct UCE errors dmesg -C modprobe einj cd /sys/kernel/debug/apei/einj echo 0x10 > error_type #memory non-fatal echo 0x23457890 > param1 #anoterh addr to test non-fatal echo 1 > error_inject dmesg # Inejct UCE fatal errors dmesg --clear # clear serial log modprobe einj cd /sys/kernel/debug/apei/einj echo 0x20 > error_type #(memory fatal) echo 0x23452222 > param1 #(another addr to test fatal) echo 1 > error_inject
grubby --update-kernel /boot/vmlinuz-$(uname -r) --args="modprobe.blacklist=ast,igc video=offb:off console=ttyS0,115200"
ssh-keygen -t rsa
# dracut_initqueue[599]: Warning: Could not boot
# -> grub 界面 quiet后输入1(单用户模式)
-> ls /dev/sdxx (找到U盤對應的設備)
-> reboot
-> 修改 vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS -> vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sdbx(U 盤設備)
# 設置crashkernel 參數到grub grubby --update-kernel=ALL --args="console=tty0 console=ttyS0,115200n8 earlyprintk=ttyS0,115200 loglevel=9 crashkernel=512M " # Enable kdump 服務 systemctl enable kdump.service systemctl start kdump.service systemctl status kdump systemctl is-active kdump # Enable CentOS-Stream-Debuginfo.repo sed 's/enabled=0/enabled=1/' -i /etc/yum.repos.d/CentOS-Stream-Debuginfo.repo # 安裝 debug kernel yum install kernel-debuginfo debuginfo-install kernel # 安裝Crash tool yum install kexec-tools yum install kernel-debug yum install crash # 使用crash 分析vmlinux crash /var/crash/xxx/vmcore /usr/lib/debug/lib/modules/4.18.0-147.5.1.el8_1.x86_64/vmlinux
sed '/GRUB_CMDLINE_LINUX_DEFAULT=/cGRUB_CMDLINE_LINUX_DEFAULT="splash text"' -i /etc/default/grub
update-grub
cp /etc/apt/sources.list /etc/apt/ sources.list.bak
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
' > /etc/apt/sources.list
apt update
# Vmware
#kernel headers
yum install kernel-devel
vmhgfs-fuse /mnt/hgfs
# Vbox
yum -y install kernel-headers kernel-devel
yum groupinstall "Development tools" #安装gcc
init 6
mount /dev/cdrom /media
#mount /dev/dvd /media
cd /media
bash ./VBoxLinuxAdditions.run
init 6
modprobe vboxsf
/etc/init.d/vboxdrv setup
mount -t vboxsf vmshare /media
# Vmware
\\.\pipe\com_1 -> /dev/ttyS1
# VBOX
\\.\pipe\com_1 -> /dev/ttyS0
# Vmware UEFI 啓動
VMware设置->选项->高级中,选择UEFI
(#Fix 固件类型无法选择UEFI“常规”,版本选择“Ubuntu64位”,工作目录选择一个别的路径)
# VBOX UEFI 啓動
設置->系統->啓用EFI
#makefile 传递宏给module
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) EXTRA_CFLAGS="-DBUILD_NUMBER=$(BUILD_NUMBER)" modules
1. 下載fwt-live測試鏡像
https://fwts.ubuntu.com/fwts-live/
https://github.com/xypron/fwts
2. 下載vbox路径
http://download.virtualbox.org/virtualbox/6.0.0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。