海运的博客

ubuntu自动安装preseed分区方法

发布时间:October 6, 2018 // 分类: // No Comments

使用自动分区,标准分区方式:

#d-i partman-auto/disk string /dev/sda
#选择第一个硬盘
d-i partman/early_command string debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/default_filesystem string ext4
d-i partman/mount_style select uuid

2018-10-06_091417.png

自动LVM分区:

d-i partman-auto/disk string /dev/sda
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/method string lvm
d-i partman-auto-lvm/guided_size string 100%
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/default_filesystem string ext4
d-i partman/mount_style select uuid

2018-10-06_091702.png

使用自定义标准分区方案,第一个数字为最小分区大小(MB),第二个获取最大分区的优先级(越小优先级越高),第三个最大分区大小。

d-i partman-auto/disk string /dev/sda
d-i partman-auto/choose_recipe select boot-root
d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true

d-i partman-auto/expert_recipe string                         \
      boot-root ::                                            \
              5120 1 5120 ext4                                \
                     $primary{ } $bootable{ }                 \
                     method{ format } format{ }               \
                     use_filesystem{ } filesystem{ ext4 }     \
                     mountpoint{ /}                           \
              .                                               \
              1 3 -1 ext4                                     \
                      $primary{ }                             \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ /home}                      \
              .                                               \
              1024 2 1024 linux-swap                          \
                      $primary{ }                             \
                      method{ swap } format{ }                \
              .

d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/default_filesystem string ext4
d-i partman/mount_style select uuid

2018-10-06_084106.png

使用自定义分区LVM:

d-i partman-auto/disk string /dev/sda
d-i partman-auto/choose_recipe select boot-lvm
d-i partman-auto/method string lvm
d-i partman-auto-lvm/guided_size string 100%
d-i partman-auto-lvm/new_vg_name string vg00
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true

d-i partman-auto/expert_recipe string                         \
      boot-lvm ::                                             \
              1024 1 1024 ext4                                \
                      $primary{ } $bootable{ }                \
                      method{ format } format{ }              \
                      use_filesystem{ } filesystem{ ext4 }    \
                      mountpoint{ /boot }                     \
              .                                               \
              1 2 -1 ext4                                     \
                      $primary{ }                             \
                      $defaultignore{ }                       \
                      method{ lvm }                           \
                      device{ /dev/sda }                      \
                      vg_name{ vg00 }                         \
              .                                               \
              1024 3 1024 swap                                \
                      $lvmok{ } lv_name{ lv_swap } in_vg{ vg00 } \
                      method{ swap } format{ }                   \
          .                                                      \
              1 4 -1 ext4                                        \
                      $lvmok{} lv_name{ lv_root } in_vg{ vg00 }  \
                      method{ format } format{ }                 \
                      use_filesystem{ } filesystem{ ext4 }       \
                      mountpoint{ / }                            \
          .                                                      

d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/default_filesystem string ext4
d-i partman/mount_style select uuid

2018-10-06_090807.png
通过preseed自动安装ubuntu系统详细配置文件见:https://www.haiyun.me/archives/1246.html
参考:
https://stackoverflow.com/questions/33923952/ubuntu-14-04-preseed-lvm-disk-config
https://cptyesterday.wordpress.com/2012/06/17/notes-on-using-expert_recipe-in-debianubuntu-preseed-files/

ubuntu18.04编译qbittorrent4.13和libtorrent1.0.11

发布时间:October 5, 2018 // 分类:PT // No Comments

qbittorrent4在使用libtorrent最新版本1.1.9版本时有诸多问题,编译使用1.0.11稳定版本试试。
安装编译环境及libtorrent依赖:

apt-get install build-essential pkg-config automake libtool git
apt-get install libboost-dev libboost-system-dev libboost-chrono-dev libboost-random-dev libssl-dev libgeoip-dev

编译libtorrent:

git clone https://github.com/arvidn/libtorrent.git
#之前系统版本可直接下载源码使用,18.04需修改include/libtorrent/export.hpp替换boost/config/为boost/config/detail/
#https://github.com/arvidn/libtorrent/releases/download/libtorrent-1_0_11/libtorrent-rasterbar-1.0.11.tar.gz
cd libtorrent
git checkout origin/RC_1_0
./autotool.sh
./configure --prefix=/usr/local/libtorrent CXXFLAGS=-std=c++11
make clean && make -j$(nproc)
make install
echo '/usr/local/libtorrent/lib' > /etc/ld.so.conf.d/libtorrent-x86_64.conf 
ldconfig
export CPLUS_INCLUDE_PATH=/usr/local/libtorrent/include/
export PKG_CONFIG_PATH=/usr/local/libtorrent/lib/pkgconfig/

安装qbittorrent依赖及编译:

apt-get install qtbase5-dev qttools5-dev-tools libqt5svg5-dev zlib1g-dev
wget https://github.com/qbittorrent/qBittorrent/archive/release-4.1.3.tar.gz
tar zxvf release-4.1.3.tar.gz 
cd qBittorrent-release-4.1.3/
./configure --prefix=/usr/local/qbittorrent --disable-gui
make clean && make -j$(nproc)
make install
export PATH=$PATH:/usr/local/qbittorrent/bin/
echo 'export PATH=$PATH:/usr/local/qbittorrent/bin/' >> ~/.bashrc

centos/linux使用vnstat统计流量

发布时间:October 4, 2018 // 分类: // No Comments

vnstat安装:

yum install vnstat
systemctl start vnstat
systemctl enable vnstat

修改默认网卡:

sed 's/Interface ".*/Interface "eth0"/' /etc/vnstat.conf

按小时统计:

vnstat -h
vnstat -i eth0 -h

按天统计:

vnstat -d

实时流量:

vnstat -l -i ens33

centos repo管理使用

发布时间:October 2, 2018 // 分类: // No Comments

使用yum-config-manager启用或关闭指定repo:

yum install yum-utils
yum-config-manager --enable remi
yum-config-manager --disable remi

安装软件时指定repo或不使用指定repo:

yum --disablerepo=remi update
yum --enablerepo=remi update

centos/debian自动通过网络远程安装系统配置脚本

发布时间:September 30, 2018 // 分类: // No Comments

此脚本用于生成ubuntu和centos网络重装引导项,ks和pressed配置文件见前文,上传到http服务器并替换脚本中内容,在centos7和ubuntu18.04上测试安装centos7和ubuntu18.04通过。

#!/bin/bash
#set -x
install=ubuntu
network=static
stage2="nfs:nfsvers=4:www.haiyun.me:/"
cidr2mask () {
  set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
  [ $1 -gt 1 ] && shift $1 || shift
  echo ${1-0}.${2-0}.${3-0}.${4-0}
}
 
function valid_ip() {
local  ip=$1
local  stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
  OIFS=$IFS
  IFS='.'; ip=($ip); IFS=$OIFS
  [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
  stat=$?
fi
return $stat
}
 
which wget &> /dev/null && which ip &> /dev/null || {
echo '请先安装wget和ip'
exit;
 }
 
 if [ "$network" == 'static' ]; then
   address=`ip -o -f inet addr show | awk '/scope global/ {print $4}'`
   ip=`echo $address|awk -F'/' '{print $1}'`
   cidr=`echo $address|awk -F'/' '{print $2}'`
   rou=`ip rou|awk '/default via/ {print $3}'`
   mask=`cidr2mask $cidr`
   echo 'ip:' $ip
   echo 'route:' $rou
   echo 'netmask:' $mask
   valid_ip "$ip"  && valid_ip "$mask"  &&  valid_ip "$rou"  || {
   echo '获取网络信息失败'
   exit;
 }
 echo '请核对以上IP信息是否正确'
fi
 
if [  -f "/etc/redhat-release" ]; then
  dist="centos"
  grubfile=/boot/grub2/grub.cfg
  grubcmd=grub2-mkconfig 
else
  grubfile=/boot/grub/grub.cfg
  grubcmd=grub-mkconfig 
  dist="ubuntu"
fi
#root=`grep "set root" $grubfile|sed -e 's/^[ \t]*//'|head -n 1`
root=`grep 'set root' $grubfile |sed -e 's/^[ \t]*//'|sort|uniq -c|head -n 1|awk '{print $2,$3}'`
if mount|grep -q /boot; then
  dir=/
else
  dir=/boot/
fi
vmlinuzfile=${dir}vmlinuz
initrdfile=${dir}initrd.img
rm -rf /boot/vmlinuz
rm -rf /boot/initrd.img
 
if [ "$install" == 'centos' ]; then
  mem=`free -m | grep Mem | awk '{print  $2}'` 
  if [ ! $stage2 ] && (($mem < 1500)); then
    echo '内存小于1.5G要通过网络安装centos7可能会失败'
    exit;
  fi
  base=https://mirrors.aliyun.com/centos/7/os/x86_64
  wget -q ${base}/isolinux/vmlinuz -O /boot/vmlinuz || exit;
  wget -q ${base}/isolinux/initrd.img -O /boot/initrd.img || exit;
  if [ "$network" == 'static' ]; then
    linux16="$vmlinuzfile inst.ks=https://www.haiyun.me/centos7.cfg net.ifnames=0 biosdevname=0 inst.headless ip=${ip}::${rou}:${mask}::eth0:none nameserver=8.8.8.8"
  else
    linux16="$vmlinuzfile inst.ks=https://www.haiyun.me/centos7.cfg net.ifnames=0 biosdevname=0 inst.headless ip=dhcp"
  fi
  if [ $stage2 ]; then
    linux16="$linux16 inst.stage2=$stage2"
  fi
else
  base=https://mirrors.aliyun.com/ubuntu/dists/bionic/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
  wget -q ${base}/linux -O /boot/vmlinuz || exit;
  wget -q ${base}/initrd.gz -O /boot/initrd.img || exit;
  if [ "$network" == 'static' ]; then
    #linux16="$vmlinuzfile ks=https://www.haiyun.me/ubuntu-ks.cfg domain= hostname=ubuntu-server interface=auto netcfg/get_ipaddress=${ip} netcfg/get_netmask=${mask} netcfg/get_gateway=${rou} netcfg/get_nameservers=8.8.8.8 netcfg/disable_autoconfig=true"
    linux16="$vmlinuzfile auto=true url=https://www.haiyun.me/ubuntu.cfg keymap=us domain= hostname=ubuntu-server interface=auto netcfg/get_ipaddress=${ip} netcfg/get_netmask=${mask} netcfg/get_gateway=${rou} netcfg/get_nameservers=8.8.8.8 netcfg/disable_autoconfig=true"
  else
    #linux16="$vmlinuzfile ks=https://www.haiyun.me/ubuntu-ks.cfg domain= hostname=ubuntu-server interface=auto"
    linux16="$vmlinuzfile auto=true url=https://www.haiyun.me/ubuntu.cfg keymap=us domain= hostname=ubuntu-server interface=auto"
  fi
fi
 
[[ -f /boot/vmlinuz ]] && [[ -f /boot/initrd.img ]] || {
echo '引导文件不存在'
exit;
}
 
cat > /etc/grub.d/40_custom <<EOF
#!/bin/sh
exec tail -n +3 \$0
menuentry 'netinstall' {
$root
linux16 $linux16
initrd16 $initrdfile
}
EOF
sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT="netinstall"/' /etc/default/grub
$grubcmd -o $grubfile
cat /etc/grub.d/40_custom

https://www.haiyun.me/archives/1246.html
https://www.haiyun.me/archives/1249.html

分类
最新文章
最近回复
  • opnfense: 谢谢博主!!!解决问题了!!!我之前一直以为内置的odhcp6就是唯一管理ipv6的方式
  • liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
  • 海运: 不好意思,没有。
  • zongboa: 您好,請問一下有immortalwrt設定guest Wi-Fi的GUI教學嗎?感謝您。
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
归档